Added another selector for price on amazon (does not work for books)

This commit is contained in:
henningxtro 2021-05-18 23:18:15 +02:00
parent 63cbac5490
commit 91a9a47f00

View File

@ -62,6 +62,7 @@ def crawl(product_ids: [int]) -> dict:
'products_with_problems': products_with_problems
}
def __crawl_amazon__(product_info: dict) -> tuple:
"""
Crawls the price for the given product from amazon
@ -71,7 +72,11 @@ def __crawl_amazon__(product_info: dict) -> tuple:
page = requests.get(product_info['url'], headers=HEADERS)
soup = BeautifulSoup(page.content, features="lxml")
try:
price = int(soup.find(id='priceblock_ourprice').get_text().replace(".", "").replace(",", "").replace("", "").strip())
price = int(
soup.find(id='priceblock_ourprice').get_text().replace(".", "").replace(",", "").replace("", "").strip())
if not price:
price = int(soup.find(id='price_inside_buybox').get_text().replace(".", "").replace(",", "").replace("", "").strip())
except RuntimeError:
price = -1
except AttributeError: