mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 09:50:20 +08:00
added screenshots and debug env
This commit is contained in:
parent
89756292a7
commit
213602b37a
@ -4,5 +4,9 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
- LOG_LEVEL=DEBUG
|
||||
ports:
|
||||
- "8191:8191"
|
||||
volumes:
|
||||
- ./screenshots:/app/screenshots
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user