refactor: короче не кликает. похоже нужно переезжать на хром

This commit is contained in:
protokey committed 2026-09-22 19:35:33 +04:00
1 parent f1ed6edc7a
commit 714cf9f922
1 file changed
+5 -10
+5 -10
View File
@@ -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: