Skip to content

Commit

Permalink
Merge pull request #236 from Crinibus/fix/add-product
Browse files Browse the repository at this point in the history
Only add product if product info is valid and update try except WebsiteVersionNotSupported
  • Loading branch information
Crinibus authored Dec 29, 2023
2 parents e0eaf06 + 49b726a commit 92a56fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions scraper/add_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def add_product(category: str, url: str) -> None:
new_product = Scraper(category, url)
new_product_info = new_product.scrape_info()

if not new_product_info.valid:
print("Product info is not valid - see logs for more info")
return

product_in_db = db.get_product_by_product_code(new_product_info.id)

if product_in_db is None:
Expand Down
4 changes: 2 additions & 2 deletions scraper/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def get_product_info(self) -> Info:
logging.getLogger(__name__).exception(f"Could not get all the data needed from url: {self.url}")
return Info(None, None, None, None, valid=False)
except WebsiteVersionNotSupported as ex:
logging.getLogger(__name__).exception(ex)
print(ex)
logging.getLogger(__name__).error(ex)
return Info(None, None, None, None, valid=False)

def _request_product_data(self) -> None:
# option for each specific class to change how the request data is being handled
Expand Down

0 comments on commit 92a56fe

Please sign in to comment.