mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2026-10-06 06:05:24 +01:00
added screenshots and debug env
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user