chore: перенос этапа прохождения антибот защиты в метод исполнения команд

это позволит выполнять проверку и обход защиты между командами
This commit is contained in:
protokey committed 2026-09-18 14:31:51 +04:00
1 parent d6bb88ead2
commit 6124c604d9
2 files changed
+27 -31

No files matched your search

+22 -2
View File
@@ -2,6 +2,7 @@ import asyncio
from playwright.async_api import Page
from antibot.orchestrator import pass_challenges
from captcha import load_captcha
from engine.schemas import ActionRequest
@@ -63,11 +64,30 @@ async def wait_for(page: Page, act: ActionRequest, **kwargs) -> str | None:
await page.wait_for_selector(act.selector, timeout=act.timeout * 1000)
async def execute(page: Page, actions: list[ActionRequest], captcha: str | None = None) -> list[dict]:
@register
async def pass_challenge(page: Page, act: ActionRequest, *, antibot_name, success_locator = None, captcha_key= None, **kwargs) -> str | None:
assert act.selector
await pass_challenges(
antibot_name, page,
captcha=captcha_key, success_locator=act.selector
)
async def execute(
page: Page, actions: list[ActionRequest],
captcha_key: str | None = None, antibot_name: str | None = None,
success_locator: str | None = None) -> list[dict]:
"""Выполнение очереди автоматизации"""
actions_result = []
ctx = {
"captcha_key": captcha,
"captcha_key": captcha_key,
"antibot_name": antibot_name,
"success_locator": success_locator
}
await pass_challenges(
antibot_name, page,
captcha=captcha, success_locator=success_locator
)
for act in actions:
new_line = {
"type": act.type,