我试图得到一些数据,当我使用lxml时,它找到了2个表,而不是我想要的第3个表。我怀疑这与xpath或生成特定表的方式有关。在
我想从:http://web.tmxmoney.com/pricehistory.php?qm_symbol=WDO.DB.A获取价格历史记录
以下是我的不同尝试和结果。在
import requests
from lxml import html
def financialPriceData():
priceData = requests.get('http://web.tmxmoney.com/pricehistory.php?qm_symbol=WDO.DB.A')
PriceScraperTree = html.fromstring(priceData.content)
#PriceTreeTickers = PriceScraperTree.xpath('//*[@id="innerContent"]/div[4]/div[1]/div[1]/div[1]/table/tbody/tr[1]/td/table/tbody/tr[5]/td/table/tbody/tr/td/table/tbody/tr[2]/td[1]/text()') # no luck. From Chrome.
# PriceTreeTickers = PriceScraperTree.xpath('//table[@id="qm_history_historyContent"]') # no luck, can't find the table
PriceTreeTickers = PriceScraperTree.xpath('//table') # no luck, finds only 2 tables top of the page and bottom of the page data. When I look at text result the daily price is missing.
print(PriceTreeTickers)
financialPriceData()
目前没有回答
相关问题 更多 >
编程相关推荐