diff --git a/backend/__pycache__/__init__.cpython-313.pyc b/backend/__pycache__/__init__.cpython-313.pyc index 5312c81..09d4c98 100644 Binary files a/backend/__pycache__/__init__.cpython-313.pyc and b/backend/__pycache__/__init__.cpython-313.pyc differ diff --git a/backend/app/__pycache__/__init__.cpython-313.pyc b/backend/app/__pycache__/__init__.cpython-313.pyc index acc1df8..aa57c88 100644 Binary files a/backend/app/__pycache__/__init__.cpython-313.pyc and b/backend/app/__pycache__/__init__.cpython-313.pyc differ diff --git a/backend/app/core/__pycache__/config.cpython-313.pyc b/backend/app/core/__pycache__/config.cpython-313.pyc index 9d7d1c1..fe587cc 100644 Binary files a/backend/app/core/__pycache__/config.cpython-313.pyc and b/backend/app/core/__pycache__/config.cpython-313.pyc differ diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 6ba3aa7..f696388 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -27,6 +27,7 @@ class ScrapeConfig(BaseModel): locale: str timezone: str proxy: str | None + debug_enabled: bool class TaxonomyConfig(BaseModel): diff --git a/backend/app/scraper/run_scrape_tests.py b/backend/app/scraper/run_scrape_tests.py index 6fd342e..c369ef4 100644 --- a/backend/app/scraper/run_scrape_tests.py +++ b/backend/app/scraper/run_scrape_tests.py @@ -153,6 +153,8 @@ def main() -> None: max_tests = int(os.getenv("SCRAPE_TEST_MAX", "0")) headful_on_block = os.getenv("SCRAPE_TEST_HEADFUL_ON_BLOCK", "0") == "1" wait_on_block = int(os.getenv("SCRAPE_TEST_WAIT_ON_BLOCK", "60")) + # Permet de forcer le debug en tests même si désactivé dans config + debug_enabled = os.getenv("SCRAPE_TEST_DEBUG_ENABLED", str(config.scrape.debug_enabled)).lower() in ("1", "true") results = [] with sync_playwright() as playwright: @@ -186,7 +188,9 @@ def main() -> None: logger.info("Scraping {} ({})", test_id, url) page.goto(url, wait_until="domcontentloaded", timeout=config.scrape.timeout_ms) - debug_files = save_debug_artifacts(page, test_id, "capture") + debug_files = {} + if debug_enabled: + debug_files = save_debug_artifacts(page, test_id, "capture") data = extract_product_data(page, url) if not data.get("titre"): logger.warning("Titre absent, suspicion de blocage pour {}", test_id) @@ -197,7 +201,8 @@ def main() -> None: manual_context = manual_browser.new_context(**manual_context_kwargs) manual_page = manual_context.new_page() manual_page.goto(url, wait_until="domcontentloaded", timeout=config.scrape.timeout_ms) - save_debug_artifacts(manual_page, test_id, "manual") + if debug_enabled: + save_debug_artifacts(manual_page, test_id, "manual") logger.info("Résoudre le captcha puis appuyer sur Entrée.") try: input() diff --git a/backend/app/scraper/runner.py b/backend/app/scraper/runner.py index 0e3ac35..17d7db1 100644 --- a/backend/app/scraper/runner.py +++ b/backend/app/scraper/runner.py @@ -172,8 +172,10 @@ def _process_product( page.goto(product.url, wait_until="domcontentloaded", timeout=config.scrape.timeout_ms) - # Toujours sauvegarder les artifacts de debug - debug_files = _save_debug_artifacts(page, product.id, "capture") + # Sauvegarder les artifacts de debug si activé dans la configuration + debug_files = {} + if config.scrape.debug_enabled: + debug_files = _save_debug_artifacts(page, product.id, "capture") # Extraire les données data = extract_product_data(page, product.url) diff --git a/backend/config_backend.json b/backend/config_backend.json index 58fbd42..88a6120 100755 --- a/backend/config_backend.json +++ b/backend/config_backend.json @@ -21,7 +21,8 @@ }, "locale": "fr-FR", "timezone": "Europe/Paris", - "proxy": null + "proxy": null, + "debug_enabled": false }, "stores_enabled": [ "amazon_fr" diff --git a/frontend/src/pages/SettingsPage.jsx b/frontend/src/pages/SettingsPage.jsx index e25c53e..1db9b83 100644 --- a/frontend/src/pages/SettingsPage.jsx +++ b/frontend/src/pages/SettingsPage.jsx @@ -388,6 +388,24 @@ const SettingsPage = () => { Désactiver pour debug manuel +
+ + + Génère des artifacts de debug dans backend/app/samples/debug/ +
+