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 # 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-gl=angle",
"--use-angle=swiftshader", "--use-angle=swiftshader",
"--test-type", "--test-type",
"--load-extension=/app/stealth-extension", # Отключено: stealth-расширение вызывает ошибки и ломает Cloudflare Turnstile
"--disable-extensions-except=/app/stealth-extension", # "--load-extension=/app/stealth-extension",
# "--disable-extensions-except=/app/stealth-extension",
]) ])
# Добавляем специальные флаги для обхода reCAPTCHA если включено # Добавляем специальные флаги для обхода 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}") logger.info(f"[{task_id}] Using new Chrome on internal port {CHROME_INTERNAL_PORT}")
# Инжектируем stealth-скрипты через CDP для дополнительной защиты # Инжектируем stealth-скрипты через CDP для дополнительной защиты
try: # Отключено: stealth-скрипты вызывают ошибки и ломают Cloudflare Turnstile
import json # try:
stealth_script_path = "/app/stealth-extension/stealth.js" # import json
if os.path.exists(stealth_script_path): # stealth_script_path = "/app/stealth-extension/stealth.js"
with open(stealth_script_path, 'r') as f: # if os.path.exists(stealth_script_path):
stealth_js = f.read() # with open(stealth_script_path, 'r') as f:
# stealth_js = f.read()
# Получаем список целей (вкладок) через CDP #
response = urllib.request.urlopen(f"{cdp_url}/json/list", timeout=5) # # Получаем список целей (вкладок) через CDP
targets = json.loads(response.read().decode()) # 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': # for target in targets:
ws_url = target.get('webSocketDebuggerUrl') # if target.get('type') == 'page':
if ws_url: # ws_url = target.get('webSocketDebuggerUrl')
logger.info(f"[{task_id}] Injecting stealth scripts via CDP into {target.get('url', 'unknown')}") # 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.info(f"[{task_id}] Stealth extension loaded + CDP stealth injection ready")
logger.warning(f"[{task_id}] Stealth script not found at {stealth_script_path}") # else:
except Exception as e: # logger.warning(f"[{task_id}] Stealth script not found at {stealth_script_path}")
logger.warning(f"[{task_id}] CDP stealth injection failed (extension should still work): {e}") # except Exception as e:
# logger.warning(f"[{task_id}] CDP stealth injection failed (extension should still work): {e}")
# Подключаемся через CDP # Подключаемся через CDP
browser = Browser(cdp_url=cdp_url) browser = Browser(cdp_url=cdp_url)