This commit is contained in:
nafer committed 2026-03-10 14:50:10 +03:00
1 parent 3bc16f775f
commit 1bedd515ae
2 files changed
+27 -25

No files matched your search

+1 -1
View File
@@ -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
+26 -24
View File
@@ -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)