当我尝试从amzaon.in打印产品价格时,输出屏幕为空白(它与flipkart btw一起使用)
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(按当前价格计算)
实际:黑屏
答案 0 :(得分:0)
价格表被亚马逊封锁。如果您查看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§ion=subscriptions&group=subscriptions&version=latest
-->
我建议您使用官方API来获取奖品。如果这不是您的选择,则必须自动化浏览器。这可以通过selenium来实现。