diff --git a/app/services/direct_search_service.py b/app/services/direct_search_service.py index 044b64c..deffb84 100644 --- a/app/services/direct_search_service.py +++ b/app/services/direct_search_service.py @@ -67,6 +67,52 @@ DEFAULT_SITE_CONFIGS = { "product_selector": ".product-list__item a, a[href*='/ref/']", "wait_selector": ".product-list", }, + # Magasins discount français + "stokomani.fr": { + "search_url": "https://www.stokomani.fr/recherche?q={query}", + "product_selector": "a.product-card, .product-item a, a[href*='/product']", + "wait_selector": ".product-card, .product-item, .search-results", + }, + "gifi.fr": { + "search_url": "https://www.gifi.fr/catalogsearch/result/?q={query}", + "product_selector": ".product-item a.product-item-link, a[href*='/produit/']", + "wait_selector": ".product-item, .products-grid", + }, + "bmstores.fr": { + "search_url": "https://www.bmstores.fr/search?q={query}", + "product_selector": "a.product-card, .product a, a[href*='/products/']", + "wait_selector": ".product-card, .product-grid", + }, + "centrakor.com": { + "search_url": "https://www.centrakor.com/recherche?search={query}", + "product_selector": "a.product-card, .product-item a", + "wait_selector": ".product-card, .product-list", + }, + "lafoirfouille.fr": { + "search_url": "https://www.lafoirfouille.fr/recherche?q={query}", + "product_selector": "a.product-item-link, .product-card a", + "wait_selector": ".product-item, .products", + }, + "tedi.fr": { + "search_url": "https://www.tedi.fr/search?q={query}", + "product_selector": "a.product-card, .product a", + "wait_selector": ".product-card, .search-results", + }, + "leclerc.fr": { + "search_url": "https://www.e.leclerc/recherche?q={query}", + "product_selector": "a.product-card, .product-tile a", + "wait_selector": ".product-card, .products-grid", + }, + "carrefour.fr": { + "search_url": "https://www.carrefour.fr/s?q={query}", + "product_selector": "a.product-card, .product-item a", + "wait_selector": ".product-card, .product-list", + }, + "auchan.fr": { + "search_url": "https://www.auchan.fr/recherche?text={query}", + "product_selector": "a.product-card, .product-tile a", + "wait_selector": ".product-card, .products", + }, } diff --git a/app/services/search_service.py b/app/services/search_service.py index 6a68e86..60aed0e 100644 --- a/app/services/search_service.py +++ b/app/services/search_service.py @@ -5,6 +5,7 @@ Combine recherche directe sur sites + Light Scraper + Browserless fallback import asyncio import logging +import os from collections.abc import AsyncGenerator from typing import Any @@ -233,6 +234,12 @@ async def _scrape_with_browserless( page_text=page_text, ) + # Construire l'URL du screenshot pour le frontend + screenshot_url = None + if screenshot_path: + screenshot_filename = os.path.basename(screenshot_path) + screenshot_url = f"/screenshots/{screenshot_filename}" + if ai_result: extraction, metadata = ai_result if extraction and extraction.price is not None: @@ -242,7 +249,7 @@ async def _scrape_with_browserless( price=extraction.price, currency=extraction.currency or "EUR", in_stock=extraction.in_stock, - image_url=None, + image_url=screenshot_url, site_name=site_name, site_domain=domain, confidence=extraction.price_confidence or 0.5, @@ -252,6 +259,7 @@ async def _scrape_with_browserless( url=url, title=fallback_title, price=None, + image_url=screenshot_url, site_name=site_name, site_domain=domain, error="AI extraction failed",