feature!: добавлен обход claudflare
не кликает!
This commit is contained in:
1 parent
40e5d046a9
commit
f1ed6edc7a
12 files changed
+171
-64
No files matched your search
+20
-2
@@ -2,6 +2,7 @@ import asyncio
|
||||
|
||||
from playwright.async_api import Page
|
||||
|
||||
from antibot.base import click_and_race
|
||||
from antibot.orchestrator import pass_challenges
|
||||
from captcha import load_captcha
|
||||
from engine.schemas import ActionRequest
|
||||
@@ -50,6 +51,18 @@ async def click(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
await element.click()
|
||||
|
||||
|
||||
@register
|
||||
async def submit(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
assert act.selector
|
||||
element = page.locator(act.selector)
|
||||
|
||||
async with page.expect_event(
|
||||
"framenavigated",
|
||||
predicate=lambda frame: frame == page.main_frame,
|
||||
):
|
||||
await element.click()
|
||||
|
||||
|
||||
@register
|
||||
async def inner_html(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
assert act.selector
|
||||
@@ -61,7 +74,10 @@ async def inner_html(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
async def wait_for(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
assert act.selector
|
||||
assert 1 <= act.timeout <= 7200
|
||||
await page.wait_for_selector(act.selector, timeout=act.timeout * 1000)
|
||||
try:
|
||||
await page.wait_for_selector(act.selector, timeout=act.timeout * 1000)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
|
||||
@register
|
||||
@@ -70,12 +86,13 @@ async def pass_challenge(
|
||||
antibot_name, success_locator=None, captcha_key=None, detect_locator=None,
|
||||
**kwargs
|
||||
) -> str | None:
|
||||
await pass_challenges(
|
||||
result = await pass_challenges(
|
||||
antibot_name, page,
|
||||
captcha=captcha_key,
|
||||
success_locator=act.selector or success_locator,
|
||||
detect_locator=detect_locator
|
||||
)
|
||||
return result.reason
|
||||
|
||||
|
||||
async def execute(
|
||||
@@ -102,6 +119,7 @@ async def execute(
|
||||
"type": act.type,
|
||||
}
|
||||
try:
|
||||
# TODO: добавить время выполнения
|
||||
result = await _actions[act.type](page, act, **ctx)
|
||||
except Exception as e:
|
||||
new_line["ok"] = False
|
||||
|
||||
Reference in new issue
Block a user