From 1bedd515aed1491e2cdd6a96a0eba6b5741c45d1 Mon Sep 17 00:00:00 2001 From: nafer Date: Tue, 10 Mar 2026 14:50:10 +0300 Subject: [PATCH] cap1 --- Dockerfile | 2 +- app.py | 50 ++++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66aa6c7..e4ede94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/playwright/python:v1.48.0-noble +FROM mcr.microsoft.com/playwright/python:v1.49.0-noble # Установка системных зависимостей # socat — проброс портов для CDP diff --git a/app.py b/app.py index 2c9bbc9..d42b199 100644 --- a/app.py +++ b/app.py @@ -826,8 +826,9 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str): "--use-gl=angle", "--use-angle=swiftshader", "--test-type", - "--load-extension=/app/stealth-extension", - "--disable-extensions-except=/app/stealth-extension", + # Отключено: stealth-расширение вызывает ошибки и ломает Cloudflare Turnstile + # "--load-extension=/app/stealth-extension", + # "--disable-extensions-except=/app/stealth-extension", ]) # Добавляем специальные флаги для обхода reCAPTCHA если включено @@ -908,28 +909,29 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str): logger.info(f"[{task_id}] Using new Chrome on internal port {CHROME_INTERNAL_PORT}") # Инжектируем stealth-скрипты через CDP для дополнительной защиты - try: - import json - stealth_script_path = "/app/stealth-extension/stealth.js" - if os.path.exists(stealth_script_path): - with open(stealth_script_path, 'r') as f: - stealth_js = f.read() - - # Получаем список целей (вкладок) через CDP - response = urllib.request.urlopen(f"{cdp_url}/json/list", timeout=5) - targets = json.loads(response.read().decode()) - - for target in targets: - if target.get('type') == 'page': - ws_url = target.get('webSocketDebuggerUrl') - if ws_url: - logger.info(f"[{task_id}] Injecting stealth scripts via CDP into {target.get('url', 'unknown')}") - - logger.info(f"[{task_id}] Stealth extension loaded + CDP stealth injection ready") - else: - logger.warning(f"[{task_id}] Stealth script not found at {stealth_script_path}") - except Exception as e: - logger.warning(f"[{task_id}] CDP stealth injection failed (extension should still work): {e}") + # Отключено: stealth-скрипты вызывают ошибки и ломают Cloudflare Turnstile + # try: + # import json + # stealth_script_path = "/app/stealth-extension/stealth.js" + # if os.path.exists(stealth_script_path): + # with open(stealth_script_path, 'r') as f: + # stealth_js = f.read() + # + # # Получаем список целей (вкладок) через CDP + # response = urllib.request.urlopen(f"{cdp_url}/json/list", timeout=5) + # targets = json.loads(response.read().decode()) + # + # for target in targets: + # if target.get('type') == 'page': + # ws_url = target.get('webSocketDebuggerUrl') + # if ws_url: + # logger.info(f"[{task_id}] Injecting stealth scripts via CDP into {target.get('url', 'unknown')}") + # + # logger.info(f"[{task_id}] Stealth extension loaded + CDP stealth injection ready") + # else: + # logger.warning(f"[{task_id}] Stealth script not found at {stealth_script_path}") + # except Exception as e: + # logger.warning(f"[{task_id}] CDP stealth injection failed (extension should still work): {e}") # Подключаемся через CDP browser = Browser(cdp_url=cdp_url)