From 213602b37aac5469bd134c3f5abc052579e662cd Mon Sep 17 00:00:00 2001 From: Thephaseless Date: Wed, 24 Jul 2024 20:38:23 +0000 Subject: [PATCH] added screenshots and debug env --- docker-compose.yaml | 4 ++++ src/utils/browser.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 14ab37e..029b6f2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,5 +4,9 @@ services: build: context: . dockerfile: Dockerfile + environment: + - LOG_LEVEL=DEBUG ports: - "8191:8191" + volumes: + - ./screenshots:/app/screenshots diff --git a/src/utils/browser.py b/src/utils/browser.py index cd44ada..b7108cc 100644 --- a/src/utils/browser.py +++ b/src/utils/browser.py @@ -1,3 +1,6 @@ +import os +from pathlib import Path + import nodriver as webdriver from nodriver.core.element import Element @@ -9,6 +12,7 @@ from src.utils.utils import CHALLENGE_TITLES async def new_browser(): config: webdriver.Config = webdriver.Config() config.sandbox = False + config.headless = bool(os.getenv("HEADLESS")) config.add_argument(f"--load-extension={','.join(downloaded_extentions)}") return await webdriver.start(config=config) @@ -23,7 +27,11 @@ async def bypass_cloudflare(page: webdriver.Tab): return challenged if not challenged: logger.info("Found challenge") + await page.save_screenshot(Path("screenshots/screenshot.png")) challenged = True + Path("screenshots").mkdir(exist_ok=True) + logger.debug("Clicking element") + await page.save_screenshot(Path("screenshots/screenshot.png")) elem = await page.query_selector(".cf-turnstile-wrapper") if isinstance(elem, Element): await elem.mouse_click()