'无法从亚马逊印度产品详情页面获取产品价格作为输出'

2024-04-27 00:18:16 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图打印产品的价格时,输出屏幕是空白的阿姆扎恩(顺便说一句,它与flipkart合作过)

url='https://www.amazon.in/Lenovo-K8-Plus-Venom-Storage/dp/B079JC4K7C/ref=sr_1_1?s=electronics&ie=UTF8&qid=1545233164&sr=1-1&keywords=lenovo%2Bk8%2Bplus&th=1'

r=requests.get(url)
soup=BeautifulSoup(r.content,"html.parser")
store=soup.find_all("div",{"class":"a-section a-spacing-small"})
for item in store:
    price = item.find_all("span",{"id":"priceblock_ourprice"})
    print(price.get_text())

预计产量:8098(按现行价格)

实际:黑屏


Tags: storeinurlget屏幕产品价格all
1条回答
网友
1楼 · 发布于 2024-04-27 00:18:16

价格表被亚马逊屏蔽了。如果您查看soup,您会发现价格没有列出,而是显示以下信息:

<!  For automated access to price change or offer listing change events,
                                             please refer to the MWS Subscription API:
                                             https://developer.amazonservices.in/gp/mws/api.html/276-5247872-0590350?ie=UTF8&section=subscriptions&group=subscriptions&version=latest
                                         >

我建议您使用官方API获取奖品。如果你没有这个选择,你将不得不自动化你的浏览器。这可以通过selenium实现。你知道吗

相关问题 更多 >