From 714cf9f9228d1ba52b18cc4b4ac00daf1776df71 Mon Sep 17 00:00:00 2001 From: protokey Date: Tue, 22 Sep 2026 19:35:33 +0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=D0=BA=D0=BE=D1=80=D0=BE=D1=87?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=20=D0=BA=D0=BB=D0=B8=D0=BA=D0=B0=D0=B5?= =?UTF-8?q?=D1=82.=20=D0=BF=D0=BE=D1=85=D0=BE=D0=B6=D0=B5=20=D0=BD=D1=83?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B5=D0=B7=D0=B6?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B0=20=D1=85=D1=80=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/antibot/known_providers/cloudflare.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/antibot/known_providers/cloudflare.py b/src/antibot/known_providers/cloudflare.py index fdc8553..0f11c6e 100644 --- a/src/antibot/known_providers/cloudflare.py +++ b/src/antibot/known_providers/cloudflare.py @@ -88,7 +88,7 @@ class CloudflareDetector(Detector): info.meta = {} widget_selector = "div.cf-turnstile[data-sitekey], div[data-sitekey].cf-turnstile" - marker_selector = info.detect_locator or "//input[@name='cf-turnstile-response']" + marker_selector = info.detect_locator or "xpath=//input[@name='cf-turnstile-response']" info.detect_locator = marker_selector log.debug(f"ищем {marker_selector} успех если есть {info.success_locator}") @@ -141,18 +141,13 @@ class CloudflareSolver(Solver): async def solve(self, page: Page, info: ChallengeInfo): if info.stage == Stage.CHECKBOX: - iframe = page.frame(url=__CF_PATTERN__) - if iframe: - frame_el = await iframe.frame_element() - box = await frame_el.bounding_box() - else: - box = await page.locator("//input[@name='cf-turnstile-response]").bounding_box() - # Calculate the Captcha coordinates for any viewport + # # Calculate the Captcha coordinates for any viewport + box = await page.locator("xpath=//input[@name='cf-turnstile-response']/../div").bounding_box() captcha_x, captcha_y = box["x"] + randint(26, 28), box["y"] + randint(25, 27) - # Move the mouse to the center of the window, then press and hold the left mouse button - # TODO: не кликает! + # # TODO: не кликает! await page.mouse.click(captcha_x, captcha_y, delay=randint(100, 200), button="left") + await wait_for_networkidle(page) if info.success_locator: