Last active
November 4, 2020 13:03
-
-
Save Abhayparashar31/7fa409915cb1130708a8e4a157407b42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def amazon(book): | |
book = book.replace(" ",'+') | |
url = f'https://www.amazon.in/s?k=python&ref=nb_sb_noss_2' | |
print(url) | |
res = requests.get(url,headers=headers) | |
soup = BeautifulSoup(res.text,'html.parser') | |
names = soup.select(".a-size-medium") | |
for i in range(len(names)): | |
try: | |
price = soup.select(".a-spacing-top-small .a-price-whole")[i].get_text().strip() | |
if price != "": | |
names = soup.select(".a-color-base.a-text-normal")[i].get_text().strip() | |
link = soup.select(" h2 .a-link-normal")[i].attrs.get("href") | |
print("https://www.amazon.in/"+str(link)) | |
print("\n") | |
except: | |
price = "" | |
names = "" | |
amazon(input("Enter the book name\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment