master
joey0629 1 year ago
parent 35b3ceed1b
commit 2b5f632408
  1. 11
      main.py

@ -86,7 +86,16 @@ def start():
url = "https://www.bea.gov/news/2024/personal-income-and-outlays-december-2023"
text = find_indicate(url)
return text
def find_indicate_bs4(url):
from bs4 import BeautifulSoup
import requests
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# 使用CSS選擇器找到元素
element = soup.select("tr",class_ ='item-fact-row' )
return element[1].text.split('+')[0]+" "+element[1].text.split('+')[1]
def find_indicate(url):
from selenium import webdriver
from selenium.webdriver.common.by import By
@ -135,7 +144,7 @@ if __name__ == "__main__":
endtimee = time.time()
print("Time_NonFarm: ", endtimee-startimee)
startimee = time.time()
print(find_indicate("https://www.bea.gov/news/2024/personal-income-and-outlays-december-2023"))
print(find_indicate_bs4("https://www.bea.gov/data/personal-consumption-expenditures-price-index"))
endtimee = time.time()
print("Time_NonFarm: ", endtimee-startimee)
# cfg = Config()

Loading…
Cancel
Save