尽管我给出了xpath,但是我无法检索到我想要的网址

时间:2019-12-09 21:13:39

标签: html python-3.x xml xpath

我想从此webpage获取视频网址的xpath,以便可以使用python下载this video

我要做的是按F12键并找到“视频”部分,然后在“视频类”下,右键单击源并复制xpath。但是我无法使用python检索网址。我得到的xpath是:

//*[@id="player"]/@src

这是我使用的python代码:

url = 'https://www.kickstarter.com/projects/peak-design/travel-tripod-by-peak-design?ref=discovery_category_newest'
res = requests.get(url=url)
tree = html.fromstring(res.text)
video_url = tree.xpath('//*[@id="player"]/@src')
print(video_url)

0 个答案:

没有答案