mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-24 15:48:11 +02:00
feat: add price verification script and update task.md to investigate comparator price extraction issues.
This commit is contained in:
1 parent
954672cfc0
commit
0ff229de13
2 files changed
+52
-2
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Identify workspace root
|
||||
sys.path.append(os.getcwd())
|
||||
|
||||
# Mock Env Vars
|
||||
os.environ["DATABASE_URL"] = "postgresql://user:password@localhost:5432/pricewatch"
|
||||
os.environ["BROWSERLESS_URL"] = "ws://localhost:3012" # Ignored by patch, but good for completeness
|
||||
|
||||
from app.services.improved_search_service import ImprovedSearchService
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(level=logging.DEBUG) # DEBUG level to see price extraction logic
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Monkey patch _connect_browser to use local launch
|
||||
async def _connect_browser_local(p):
|
||||
logger.info("Launching local browser (headless)...")
|
||||
return await p.chromium.launch(headless=True)
|
||||
|
||||
|
||||
ImprovedSearchService._connect_browser = _connect_browser_local
|
||||
|
||||
|
||||
async def test_search():
|
||||
await ImprovedSearchService.initialize()
|
||||
|
||||
query = "nintendo switch"
|
||||
target_site = "stokomani.fr"
|
||||
|
||||
print(f"Searching for: {query} on {target_site}")
|
||||
|
||||
async for result in ImprovedSearchService.search_site_generator(target_site, query):
|
||||
print(f"[{result.source}] {result.title}\n -> Price: {result.price}€\n -> URL: {result.url}")
|
||||
|
||||
await ImprovedSearchService.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_search())
|
||||
Reference in new issue
Block a user