diff --git a/inspect_lincroyable.py b/inspect_lincroyable.py index a514b9c..177ecd8 100644 --- a/inspect_lincroyable.py +++ b/inspect_lincroyable.py @@ -11,10 +11,14 @@ from app.services.browserless_service import browserless_service # Configure logging logging.basicConfig(level=logging.INFO) + async def inspect(): url = "https://www.lincroyable.fr/recherche-query=iphone/" print(f"Inspecting {url}...") - + + # Use host port for local debugging + os.environ["BROWSERLESS_URL"] = "ws://localhost:3012" + await browserless_service.initialize() try: content, _ = await browserless_service.get_page_content(url, wait_selector="body") @@ -24,5 +28,6 @@ async def inspect(): finally: await browserless_service.shutdown() + if __name__ == "__main__": asyncio.run(inspect()) diff --git a/inspect_local_playwright.py b/inspect_local_playwright.py new file mode 100644 index 0000000..ed34dc8 --- /dev/null +++ b/inspect_local_playwright.py @@ -0,0 +1,47 @@ +import asyncio +import logging +import os +from playwright.async_api import async_playwright + +# Configure logging +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + + +async def inspect_local(): + url = "https://www.lincroyable.fr/recherche-query=iphone/" + print(f"Inspecting {url} using local Playwright...") + + async with async_playwright() as p: + # Launch local browser (headless=True matches server environment usually, but we can try False to see) + browser = await p.chromium.launch(headless=True) + context = await browser.new_context( + user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" + ) + page = await context.new_page() + + try: + logging.info(f"Navigating to {url}") + await page.goto(url, timeout=30000) + logging.info("Navigation successful") + + content = await page.content() + with open("lincroyable_local_dump.html", "w", encoding="utf-8") as f: + f.write(content) + print("HTML dumped to lincroyable_local_dump.html") + + await page.screenshot(path="lincroyable_local.png") + print("Screenshot saved to lincroyable_local.png") + + except Exception as e: + logging.error(f"Error: {e}") + try: + await page.screenshot(path="lincroyable_error.png") + except: + pass + finally: + await browser.close() + + +if __name__ == "__main__": + asyncio.run(inspect_local()) diff --git a/lincroyable_local.png b/lincroyable_local.png new file mode 100644 index 0000000..e470194 Binary files /dev/null and b/lincroyable_local.png differ diff --git a/lincroyable_local_dump.html b/lincroyable_local_dump.html new file mode 100644 index 0000000..4aac0b5 --- /dev/null +++ b/lincroyable_local_dump.html @@ -0,0 +1,1600 @@ + + + + + + + + iphone - L'Incroyable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
+ +
+
+
+

Recherche

26 résultats pour votre recherche "iphone"

+ +
+
+ +
+
+
+ + + +
+
+ +
+
+
+
+
+ retour Top +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file