no_pages = 2 def get_data(pageNo): headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:6 r = requests.get('https://www.amazon.in/gp/bestsellers/books/ref=zg_bs_ content = r.content soup = BeautifulSoup(content) #print (soup) alls = [] for d in soup.findAll('div', attrs={'class':'a-section a-spacing-none a #print (d) name = d.find('span', attrs={'class':'zg-text-center-align'}) n = name.find_all('img', alt=True) #print(n[0]['alt']) author = d.find('a', attrs={'class':'a-size-small a-link-child'}) rating = d.find('span', attrs={'class':'a-icon-alt'}) users_rated = d.find('a', attrs={'class':'a-size-small a-link-norma price = d.find('span', attrs={'class':'p13n-sc-price' }) all1=[] if name is not None: #print(n[0]['alt']) al11.append(n[0]['alt']) else: al11.append("unknown-product") if author is not None: if author is not None: #print(author.text) al11.append(author.text) elif author is None: author = d.find('span', attrs={'class':'a-size-small a-color-ba if author is not None: al11.append(author.text) else: if rating is not None: #print (rating.text) al11.append(rating.text) else: al11.append('0') all1.append('-1') if users_rated is not None: #print (price.text) al11.append(users_rated.text) else: al11.append('0') if price is not None: #print (price.text) al11.append(price.text) else: al11.append('0') alls.append(all1) return alls