From 7ba88508381c85bc6b8e73cb246fc9ea9c286629 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Sun, 30 Nov 2025 16:36:51 +0100 Subject: [PATCH] feat: Implement new search service with comprehensive configuration for various e-commerce sites, proxies, and user agents. --- app/core/search_config.py | 18 +++++++++--------- app/services/improved_search_service.py | 14 ++++++++------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/core/search_config.py b/app/core/search_config.py index 6fa3c26..d234391 100644 --- a/app/core/search_config.py +++ b/app/core/search_config.py @@ -120,9 +120,9 @@ SITE_CONFIGS = { "fnac.com": { "name": "Fnac", "search_url": "https://www.fnac.com/SearchResult/ResultList.aspx?Search={query}", - "product_selector": "a.Article-title[href*='/a']", - "product_image_selector": "img.Article-itemVisual, img[data-src], img[src*='product'], picture img", - "wait_selector": ".Article-item, .Article-list", + "product_selector": "a[href*='/a'], a.Article-title, article a", + "product_image_selector": "img, picture source", + "wait_selector": ".Article-item", "category": "Culture & Tech", "requires_proxy": False, }, @@ -158,9 +158,9 @@ SITE_CONFIGS = { "e-leclerc.com": { "name": "E.Leclerc", "search_url": "https://www.e-leclerc.com/recherche?text={query}", - "product_selector": "a[data-testid='product-link'], a[href*='/cat/'][href*='/sku/']", - "product_image_selector": "img[data-testid='product-image'], img[src*='scene7'], img[loading='eager']", - "wait_selector": "[data-testid='product-card'], [data-testid='product-link']", + "product_selector": "a[href*='/cat'], a[href*='/produit'], article a, div[class*='product'] a", + "product_image_selector": "img, picture source", + "wait_selector": None, "category": "Grande Surface", "requires_proxy": False, }, @@ -176,9 +176,9 @@ SITE_CONFIGS = { "carrefour.fr": { "name": "Carrefour", "search_url": "https://www.carrefour.fr/s?q={query}", - "product_selector": "a[data-testid='product-card-link'], a.product-card__link", - "product_image_selector": "img[data-testid='product-card-image'], img[fetchpriority], img.ds-product-image__img", - "wait_selector": "[data-testid='product-card'], article[data-testid]", + "product_selector": "a[href*='/p/'], a[href*='/produit'], article a, div[class*='product'] a", + "product_image_selector": "img, picture source", + "wait_selector": None, "category": "Grande Surface", "requires_proxy": False, }, diff --git a/app/services/improved_search_service.py b/app/services/improved_search_service.py index d9613a1..b7fea94 100644 --- a/app/services/improved_search_service.py +++ b/app/services/improved_search_service.py @@ -314,16 +314,18 @@ class ImprovedSearchService: if not title or len(title) < 3: continue - # STRICT FILTERING: Check if all query words are in the title + # RELAXED FILTERING: Check if at least ONE query word is in the title + # (instead of ALL words, which was too strict) title_lower = title.lower() if query_words: - all_words_found = True + at_least_one_word_found = False for word in query_words: - if word not in title_lower: - all_words_found = False + if word in title_lower: + at_least_one_word_found = True break - - if not all_words_found: + + # Only keep results with at least one matching word + if not at_least_one_word_found: continue # Extract Image URL - PRIORITIZE CONFIGURED SELECTOR