feature: переезд на хром
This commit is contained in:
1 parent
714cf9f922
commit
f2d4d441f4
6 files changed
+355
-102
No files matched your search
@@ -68,7 +68,7 @@ from playwright.async_api import Page
|
||||
from ..base import Detector, ChallengeInfo, AntiBotProvider, Solver
|
||||
from ..base import Stage
|
||||
from ..registry import register
|
||||
from ..humanize import wait_for_page_stability, wait_for_networkidle
|
||||
from ..humanize import wait_for_page_stability, wait_for_networkidle, click_human
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(logging.DEBUG)
|
||||
@@ -140,13 +140,21 @@ __CF_PATTERN__ = re.compile(r"^https://challenges\.cloudflare\.com/cdn-cgi/chall
|
||||
class CloudflareSolver(Solver):
|
||||
|
||||
async def solve(self, page: Page, info: ChallengeInfo):
|
||||
iframe = page.frame(url=__CF_PATTERN__)
|
||||
if iframe:
|
||||
await page.wait_for_timeout(randint(4000, 7000)) # дать чекбоксу домонтироваться в closed shadow root
|
||||
frame_el = await iframe.frame_element()
|
||||
box = await frame_el.bounding_box()
|
||||
else:
|
||||
box = await page.query_selector("xpath=//input[@name='cf-turnstile-response']/../div").bounding_box()
|
||||
|
||||
if info.stage == Stage.CHECKBOX:
|
||||
# # 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)
|
||||
|
||||
# # 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 click_human(page, captcha_x, captcha_y)
|
||||
|
||||
await wait_for_networkidle(page)
|
||||
|
||||
|
||||
Reference in new issue
Block a user