From 3478d8abbe6df24aae429df28d235b91e51247e9 Mon Sep 17 00:00:00 2001 From: gilles Date: Sat, 7 Feb 2026 15:35:09 +0100 Subject: [PATCH] add debug option --- backend/__pycache__/__init__.cpython-313.pyc | Bin 216 -> 206 bytes .../app/__pycache__/__init__.cpython-313.pyc | Bin 227 -> 217 bytes .../core/__pycache__/config.cpython-313.pyc | Bin 2210 -> 2312 bytes backend/app/core/config.py | 1 + backend/app/scraper/run_scrape_tests.py | 9 +++++++-- backend/app/scraper/runner.py | 6 ++++-- backend/config_backend.json | 3 ++- frontend/src/pages/SettingsPage.jsx | 18 ++++++++++++++++++ 8 files changed, 32 insertions(+), 5 deletions(-) diff --git a/backend/__pycache__/__init__.cpython-313.pyc b/backend/__pycache__/__init__.cpython-313.pyc index 5312c8105f5ecc25bc0c9fb1e8b35eeb50721834..09d4c98e0e55dc78e0ccb6cf1d44507ff044f833 100644 GIT binary patch delta 43 xcmcb?c#e_#GcPX}0}z~6D4WQgA!4eZk)NBYpPreMlUl5wlAoNNS~PK@I{+9)4iEqU delta 53 zcmX@dc!QDqGcPX}0}yl diff --git a/backend/app/__pycache__/__init__.cpython-313.pyc b/backend/app/__pycache__/__init__.cpython-313.pyc index acc1df8b9499ce9b684b2d6497f4f10904f658f8..aa57c888b72d7264f688dee547e5d3c24c8dd04a 100644 GIT binary patch delta 43 xcmaFNc$1O)GcPX}0}z~6D4WQgFJh^mk)NBYpPreMlUl5wlAoNNS~PKnHvk;}4m;z zprA+!#9}K>E=nv&Ez$vT_=-#Ni&BeWRuySYc4yPzG5~1<5o(hw+0+>gCNE@D;9>*v znHd-uKl@ES&8Ax)#17=6fndg9CQC+BMu@NqgC?_I6>Dipny!T=<1LQVyyX0p%)E3> z7O>g3gmd##Qgh6ztL>+sW_Q yWx3pd(jc!Dw@nt~@ZsTRl$c=og#k!?k(r#wp&}H<_?el3N$evN6Jr=7*a`p(D27S^ delta 404 zcmeAWS|rH(nU|M~0SM}+=VU5v0G#3FtW0n%6`0VHm5 z*yQG?l;)(`6*&XBAV(IrOs?Ya;o)Kwn_&5c0Z4t3ntX{vMZoYgGXs;@M 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/ +
+