用Python从股票行情器上获取雅虎财经4年多的基本数据

2024-05-19 14:32:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用Python从Yahoo Finance获得某只股票的基本面数据,比如现金流数据。在

我试图找到一种方法来使用api获取这些信息,但没有成功。使用此代码:

url = 'https://finance.yahoo.com/quote/' + symbol + '/balance-sheet?p=' + 
page = requests.get(url)
tree = html.fromstring(page.content)

# Using XPATH, fetch all table elements on the page
table = tree.xpath('//table') 
tstring = lxml.etree.tostring(table[0], method='html')
df = pd.read_html(tstring)[0]

我可以将股票代码的资产负债表加载到熊猫数据框中,但它只有过去4年的时间。在

我需要找到一种方法来进一步了解财务数据,而不是仅仅4年,如果可能的话,还要得到所有季度的数据。在


Tags: 数据方法api信息treeurlhtmlpage