From 48f149d38fbee7a952a6ad39e90a69b65c3b4315 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Mon, 22 Dec 2025 16:05:07 +0100 Subject: [PATCH] feat: implement improved search service with persistent browser connection and update search verification script. --- app/services/improved_search_service.py | 20 -------------------- verify_search_price.py | 4 ++-- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/app/services/improved_search_service.py b/app/services/improved_search_service.py index 42b9798..4ed3e8d 100644 --- a/app/services/improved_search_service.py +++ b/app/services/improved_search_service.py @@ -409,26 +409,6 @@ class ImprovedSearchService: async def _scrape_item_details(cls, result: SearchResult, context: BrowserContext) -> SearchResult | None: """Scrape price and details for a single item using same context""" try: - # SPECIAL CASE: L'Incroyable - Price is in the title - if "lincroyable.fr" in result.url: - import re - - # Extract price from title (e.g., "34€99" or "59€99") - # Extract price from title (e.g., "34€99" or "59€99") - # Fix: Use non-greedy regex and ensure only 2 decimals - price_match = re.search(r"(\d+)€(\d{2})(?!\d)", result.title) - if price_match: - # Convert to float (e.g., "34€99" -> 34.99) - price_euros = int(price_match.group(1)) - price_cents = int(price_match.group(2)) - result.price = float(f"{price_euros}.{price_cents}") - - # Clean title by removing price - result.title = re.sub(r"\d+€\d+", "", result.title).strip() - logger.debug(f"L'Incroyable - Extracted price {result.price}€ from title") - - return result - # SPECIAL CASE: Gifi - Price extracted from search, no need to visit page if "gifi.fr" in result.url and result.price is not None: logger.debug(f"Gifi - Price already extracted from search: {result.price}€") diff --git a/verify_search_price.py b/verify_search_price.py index a83fd35..00bd5ca 100644 --- a/verify_search_price.py +++ b/verify_search_price.py @@ -30,8 +30,8 @@ ImprovedSearchService._connect_browser = _connect_browser_local async def test_search(): await ImprovedSearchService.initialize() - query = "Mange-debout" # Common item on their site - target_site = "lincroyable.fr" + query = "nintendo switch" + target_site = "gifi.fr" print(f"Searching for: {query} on {target_site}")