-
-
Save creativesalam/a3d18a6fe353673c81452e9ee0d23df7 to your computer and use it in GitHub Desktop.
This file contains 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
# product title | |
title = soup.find(id='productTitle').get_text().strip() | |
# to prevent script from crashing when there isn't a price for the product | |
try: | |
price = float(soup.find(id='priceblock_ourprice').get_text().replace('.', '').replace('€', '').replace(',', '.').strip()) | |
except: | |
price = '' | |
# review score | |
review_score = float(soup.select('.a-star-4-5')[0].get_text().split(' ')[0].replace(",", ".")) | |
# how many reviews | |
review_count = int(soup.select('#acrCustomerReviewText')[0].get_text().split(' ')[0].replace(".", "")) | |
# checking if there is "Out of stock" and if not, it means the product is available | |
try: | |
soup.select('#availability .a-color-state')[0].get_text().strip() | |
stock = 'Out of Stock' | |
except: | |
stock = 'Available' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment