【发布时间】:2021-12-18 18:44:34
【问题描述】:
我正在尝试使用 lxml 和 Python 中的请求从网站中提取一些数据。 这是URL
这是我的代码:
from lxml import html
import requests
page = requests.get('https://www.google.com/finance/quote/HPQ:NYSE?comparison=NASDAQ%3AINTC%2CNASDAQ%3AAAPL%2CNASDAQ%3AAVGO%2CNASDAQ%3AQCOM')
tree = html.fromstring(page.content)
price = tree.xpath('//*[@id="yDmH0d"]/c-wiz/div/div[4]/div/div/main/div[2]/c-wiz/div/div[5]/div/div/div/div[1]/div[1]')
但是,当我查看price 时,它是空的。
我做错了什么?
【问题讨论】:
标签: python web-scraping xpath python-requests lxml