Annotate products that could not be found by scrapers
This commit is contained in:
parent
d69f35cfcc
commit
650aef9794
3 changed files with 32 additions and 3 deletions
|
@ -14,6 +14,11 @@ from typing import List
|
|||
vat = Decimal('1.09')
|
||||
|
||||
|
||||
class ProductNotFoundError(Exception):
|
||||
def __init__(self):
|
||||
super().__init__('product not found')
|
||||
|
||||
|
||||
@dataclass
|
||||
class Product:
|
||||
name: str
|
||||
|
@ -35,7 +40,12 @@ def ah_get_by_gtin(gtin13):
|
|||
if not _ah:
|
||||
_ah = AHConnector()
|
||||
|
||||
ah_prod = _ah.get_product_by_barcode(gtin13)
|
||||
try:
|
||||
ah_prod = _ah.get_product_by_barcode(gtin13)
|
||||
except requests.exceptions.HTTPError as err:
|
||||
if err.response.status_code == 404:
|
||||
raise ProductNotFoundError()
|
||||
raise err
|
||||
|
||||
units_description = ah_prod['salesUnitSize']
|
||||
units = 1
|
||||
|
@ -88,7 +98,7 @@ def sligro_get_by_gtin(gtin13):
|
|||
if 'products' in body:
|
||||
break
|
||||
else:
|
||||
raise Exception(f'sligro: {gtin13} not found')
|
||||
raise ProductNotFoundError()
|
||||
|
||||
product = body['products'][0]
|
||||
sku = product["code"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue