使用 python 中的 BeautifulSoup 从 google 财务中抓取数据

Scraping data from google finance using BeautifulSoup in python

我正在尝试从 google finance from this link 获取数据,如下所示:

url = "https://www.google.com/finance/historical?cid=4899364&startdate=Dec+1%2C+2016&enddate=Mar+23%2C+2017&num=200&ei=4wLUWImyJs-iuASgwIKYBg"
request = urllib.request.Request(url,None,headers)
response = urllib.request.urlopen(request).read()
soup = BeautifulSoup(response, 'html.parser')
prices = soup.find_all("tbody")
print(prices)

我得到一个空列表。我也尝试过使用 soup.find_all('tr') 等替代方法,但我仍然无法成功检索数据。

编辑:

headers={'Host': 'www.google.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Connection': 'keep-alive'
}

问题出在 html.parser。我改为使用 lxml 并且它有效。还与请求交换了 urllib。