cap4
This commit is contained in:
1 parent
b55f8c5318
commit
8eccfa1833
2 files changed
+25
No files matched your search
@@ -965,6 +965,28 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str):
|
|||||||
|
|
||||||
agent = Agent(**agent_kwargs)
|
agent = Agent(**agent_kwargs)
|
||||||
|
|
||||||
|
# Автоматическое решение капчи перед запуском, если включено
|
||||||
|
if AUTO_SOLVE_CAPTCHA and CAPSOLVER_API_KEY:
|
||||||
|
try:
|
||||||
|
# Получаем страницу через browser_use
|
||||||
|
from browser_use import BrowserSession
|
||||||
|
browser_session = BrowserSession(browser=browser)
|
||||||
|
page = await browser_session.get_current_page()
|
||||||
|
if page:
|
||||||
|
# Проверяем наличие капчи
|
||||||
|
captcha_found = await page.query_selector('[data-sitekey]')
|
||||||
|
turnstile_found = await page.query_selector('iframe[src*="turnstile"]')
|
||||||
|
if captcha_found or turnstile_found:
|
||||||
|
logger.info(f"[{task_id}] CAPTCHA detected, attempting to solve automatically...")
|
||||||
|
# Вызываем функцию решения капчи
|
||||||
|
solved = await solve_captcha_with_capsolver(page, CAPSOLVER_API_KEY)
|
||||||
|
if solved:
|
||||||
|
logger.info(f"[{task_id}] CAPTCHA solved successfully!")
|
||||||
|
else:
|
||||||
|
logger.warning(f"[{task_id}] Failed to solve CAPTCHA automatically")
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"[{task_id}] Auto-captcha solve failed: {e}")
|
||||||
|
|
||||||
# Выполнение задачи
|
# Выполнение задачи
|
||||||
history: AgentHistoryList = await agent.run(max_steps=max_steps)
|
history: AgentHistoryList = await agent.run(max_steps=max_steps)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ services:
|
|||||||
- LLM_MODEL_NAME=${LLM_MODEL_NAME:-arcee-ai/trinity-large-preview:free}
|
- LLM_MODEL_NAME=${LLM_MODEL_NAME:-arcee-ai/trinity-large-preview:free}
|
||||||
- REMOTE_DEBUGGING_ENABLED=true
|
- REMOTE_DEBUGGING_ENABLED=true
|
||||||
- REMOTE_DEBUGGING_PORT=9222
|
- REMOTE_DEBUGGING_PORT=9222
|
||||||
|
# CapSolver для автоматического решения капчи (Turnstile, reCAPTCHA, hCaptcha)
|
||||||
|
- CAPSOLVER_API_KEY=${CAPSOLVER_API_KEY:-}
|
||||||
|
- AUTO_SOLVE_CAPTCHA=${AUTO_SOLVE_CAPTCHA:-false}
|
||||||
volumes:
|
volumes:
|
||||||
- /home/nafer/dokploy_data/browser-use:/app/browser-data
|
- /home/nafer/dokploy_data/browser-use:/app/browser-data
|
||||||
shm_size: '4gb'
|
shm_size: '4gb'
|
||||||
|
|||||||
Reference in new issue
Block a user