Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to scrap the partner offers given in amazon laptop products webspace. but when i do it i get no values.

What I have tried:

i tried to get the no of partner offers given in amazon laptop website
here is the imgur img link which describe it more:Imgur: The magic of the Internet[^]

when i tried to scrap it it gives "none" value as output

here is my code used to scrap it

from bs4 import BeautifulSoup
import pandas as pd
import requests
import csv

headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0", "Accept-Encoding":"gzip, deflate", "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "DNT":"1","Connection":"close", "Upgrade-Insecure-Requests":"1"}
url= "https://www.amazon.in/dp/B0BGZN7FWV"
page = requests.get(url, headers = headers)
content =page.content
soup=BeautifulSoup(content)


PartnerofferNo=soup.find('a', attrs={"class":"a-size-base a-link-emphasis vsx-offers-count"})
print(PartnerofferNo)
Posted
Updated 13-Jan-23 23:21pm

It gives "none" because there is no matching a tag with that class.

If nothing matches, nothing is returned.

Use the debugger, look at exactly what your content is, and work from there. You really should be using the API, as you were told days ago ...
 
Share this answer
 
As already explained in your original post of this question: Issues in webscraping Python[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900