Reputation: 59
The output screen is blank when i try to print the price of a product from amzaon.in (it worked with 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())
Expected output: 8098(as of current price)
Actual: blank screen
Upvotes: 1
Views: 448
Reputation: 1673
The price listing gets blocked by amazon. If you look at soup
you can find that the price is not listed but instead it shows the follwoing message:
<!-- 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
-->
I would advise you to use the official API to fetch prizes. If this is no option for you you will have to automate your browser. This could be achieved with selenium.
Upvotes: 1