-1
from lxml import html
import requests
import time
#Gets prices
page = requests.get('https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=hi')
tree = html.fromstring(page.content)
price = tree.xpath('//h2[@data-attribute="Hi Guess the Food - What’s the Food Brand in the Picture"]/text()')
print(price)
这只能返回[]如何让代码使用xpath返回文本?
当寻找到page.content,它显示了亚马逊的反僵尸的东西。我怎样才能绕过这个?
那么,你有没有看过'page.content'? – vaultah