mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-11 17:29:14 +02:00
feat: Add more site configs and fix screenshot display
- Add search URLs for French discount stores: stokomani, gifi, bmstores, centrakor, lafoirfouille, tedi, leclerc, carrefour, auchan - Fix screenshot URL construction in search results - Include screenshot_url in AI extraction results and error cases
This commit is contained in:
2 files changed
+55
-1
No files matched your search
@@ -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",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user