Python 2.7 通过一系列股票报价器从网上抓取雅虎的财务数据

Python 2.7 通过一系列股票报价器从网上抓取雅虎的财务数据,python-2.7,beautifulsoup,yahoo,yahoo-finance,Python 2.7,Beautifulsoup,Yahoo,Yahoo Finance,我正试图从雅虎财务公司那里获取财务汇总表。我希望通过列表或csv文件来完成,而不是一个接一个地完成 目前我可以刮取多个表,但当我尝试使用df.read_html时,它只会给我一个表 有人知道更好的方法吗?到目前为止,我的代码是: import requests import pandas as pd from bs4 import BeautifulSoup with open('ticker_list_test.csv') as f: for ticker in map(str.s

我正试图从雅虎财务公司那里获取财务汇总表。我希望通过列表或csv文件来完成,而不是一个接一个地完成

目前我可以刮取多个表,但当我尝试使用df.read_html时,它只会给我一个表

有人知道更好的方法吗?到目前为止,我的代码是:

import requests
import pandas as pd
from bs4 import BeautifulSoup


with open('ticker_list_test.csv') as f:
    for ticker in map(str.strip,f):
        url = "https://finance.yahoo.com/quote/{}".format(ticker)
        r = requests.get(url)
        soup = BeautifulSoup(r.content)
        yahoo_table = soup.find_all("table", "W(100%)")
        print(yahoo_table)
df = pd.read_html(str(yahoo_table))
我的ticker\u list\u test.cvs只是3个股票代码符号——AAPL、SPY和NFLX

感谢

将open('ticker\u list\u test.csv','r')作为f:open('ticker\u list\u test.csv','r')作为f: