refactor: короче не кликает. похоже нужно переезжать на хром
This commit is contained in:
1 parent
f1ed6edc7a
commit
714cf9f922
1 file changed
+5
-10
@@ -88,7 +88,7 @@ class CloudflareDetector(Detector):
|
|||||||
|
|
||||||
info.meta = {}
|
info.meta = {}
|
||||||
widget_selector = "div.cf-turnstile[data-sitekey], div[data-sitekey].cf-turnstile"
|
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
|
info.detect_locator = marker_selector
|
||||||
|
|
||||||
log.debug(f"ищем {marker_selector} успех если есть {info.success_locator}")
|
log.debug(f"ищем {marker_selector} успех если есть {info.success_locator}")
|
||||||
@@ -141,18 +141,13 @@ class CloudflareSolver(Solver):
|
|||||||
|
|
||||||
async def solve(self, page: Page, info: ChallengeInfo):
|
async def solve(self, page: Page, info: ChallengeInfo):
|
||||||
if info.stage == Stage.CHECKBOX:
|
if info.stage == Stage.CHECKBOX:
|
||||||
iframe = page.frame(url=__CF_PATTERN__)
|
# # Calculate the Captcha coordinates for any viewport
|
||||||
if iframe:
|
box = await page.locator("xpath=//input[@name='cf-turnstile-response']/../div").bounding_box()
|
||||||
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
|
|
||||||
captcha_x, captcha_y = box["x"] + randint(26, 28), box["y"] + randint(25, 27)
|
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 page.mouse.click(captcha_x, captcha_y, delay=randint(100, 200), button="left")
|
||||||
|
|
||||||
await wait_for_networkidle(page)
|
await wait_for_networkidle(page)
|
||||||
|
|
||||||
if info.success_locator:
|
if info.success_locator:
|
||||||
|
|||||||
Reference in new issue
Block a user