mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2026-10-06 06:05:24 +01:00
use const for logging level
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from src.utils.consts import LOG_LEVEL
|
||||
|
||||
logger = logging.getLogger("uvicorn.error")
|
||||
logger.setLevel(os.getenv("LOG_LEVEL") or logging.INFO)
|
||||
logger.setLevel(LOG_LEVEL)
|
||||
if len(logger.handlers) == 0:
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import nodriver as webdriver
|
||||
from nodriver.core.element import Element
|
||||
|
||||
from src.utils import logger
|
||||
from src.utils.consts import CHALLENGE_TITLES
|
||||
from src.utils.extentions import downloaded_extentions
|
||||
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,6 +21,7 @@ async def bypass_cloudflare(page: webdriver.Tab):
|
||||
while True:
|
||||
await page
|
||||
await page.wait(0.5)
|
||||
logger.debug(page.target.title)
|
||||
if page.target.title not in CHALLENGE_TITLES:
|
||||
return challenged
|
||||
if not challenged:
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
LOG_LEVEL = os.getenv("LOG_LEVEL") or "INFO"
|
||||
LOG_LEVEL = logging.getLevelName(LOG_LEVEL)
|
||||
|
||||
CHALLENGE_TITLES = [
|
||||
# Cloudflare
|
||||
"Just a moment...",
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
from venv import logger
|
||||
|
||||
import nodriver as webdriver
|
||||
from nodriver.core.element import Element
|
||||
|
||||
from src.utils.consts import CHALLENGE_TITLES
|
||||
|
||||
|
||||
async def new_browser():
|
||||
config: webdriver.Config = webdriver.Config()
|
||||
config.sandbox = False
|
||||
|
||||
return await webdriver.start(config=config)
|
||||
|
||||
|
||||
async def bypass_cloudflare(page: webdriver.Tab):
|
||||
while True:
|
||||
await page
|
||||
if page.target.title not in CHALLENGE_TITLES:
|
||||
break
|
||||
elem = await page.query_selector(".cf-turnstile-wrapper")
|
||||
if isinstance(elem, Element):
|
||||
logger.info(f"Clicking element: {elem}")
|
||||
await elem.mouse_click()
|
||||
Reference in New Issue
Block a user