mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-12-23 04:05:12 +00:00
Added another selector for price on amazon (does not work for books)
This commit is contained in:
parent
63cbac5490
commit
91a9a47f00
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user