【发布时间】:2020-08-30 07:50:26
【问题描述】:
我正在尝试从雅虎财经网站提取日期,但是当文本生成时,只显示时间而不显示日期
import requests
import re
from bs4 import BeautifulSoup
technicals = {}
ticker = "INFY.NS"
try:
url = "https://finance.yahoo.com/quote/" + ticker + "/key-statistics?p=" + ticker
r = requests.get(url)
# soup = BeautifulSoup(open("Yahoo Stats.html"), 'lxml')
soup = BeautifulSoup(r.text, 'lxml')
t = soup.find('span', {"class": "Trsdu(0.3s) Fw(b) Fz(36px) Mb(-4px) D(ib)"})
technicals["CMP"] = t.text
# d = soup.find('span', {"class": "C($tertiaryColor) D(b) Fz(12px) Fw(n) Mstart(0)--mobpsm Mt(6px)--mobpsm"})
d = soup.find('div', attrs={'id': 'quote-market-notice'})
print(d.text)
代码继续运行。
谁能帮忙获取日期和时间
【问题讨论】:
标签: python beautifulsoup yahoo-finance