-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