From 8047b06253871adfa5466601114da87957a19948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Thu, 5 Mar 2026 20:00:23 +0100 Subject: [PATCH] fix: sauvegarde toute les 5 pages --- src/scraper.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scraper.py b/src/scraper.py index 5f45d30..bc599a6 100755 --- a/src/scraper.py +++ b/src/scraper.py @@ -384,8 +384,7 @@ class Scraper: list[dict[str, Any]], data.get("products") ) - if isinstance(products, list): - return products + return products except (JSONDecodeError, HTTPError): return None @@ -461,12 +460,18 @@ class Scraper: products_list, bar_format=custom_format ) for product in pbar: - keyword = product.get("seoKeyword", "Inconnu")[:40] + keyword: str = cast( + str, product.get("seoKeyword", "Inconnu")[:40] + ) pbar.set_description( f"Page: {page:<3} | Product: {keyword:<40}" ) self._writevins(cache, product, f) page += 1 + # va créer un fichier au début et l'override + # tout les 5 pages au cas où SIGHUP ou autre + if page % 5 == 0 and not reset: + savestate((page, cache)) except (Exception, HTTPError, KeyboardInterrupt, JSONDecodeError): if not reset: savestate((page, cache))