fix: повышение стабильности обхода cf_turnstile

This commit is contained in:
protokey committed 2026-09-23 16:48:55 +04:00
1 parent 405e5ed2d0
commit dc441e60ef
2 files changed
+18 -2

No files matched your search

+12 -1
View File
@@ -61,6 +61,7 @@ iFrame with checkbox
import logging
import re
import time
import traceback
from random import randint
from patchright.async_api import Page
@@ -158,7 +159,17 @@ class CloudflareDetector(Detector):
"managed",
"interactive",
)
page_content = await page.content()
for _ in range(2):
try:
page_content = await page.content()
except Exception:
traceback.print_exc()
await wait_for_page_stability(page, True, True)
continue
else:
break
for ctype in challenge_types:
if f"cType: '{ctype}'" in page_content:
return ctype
+6 -1
View File
@@ -3,6 +3,7 @@
"""
import logging
import time
import traceback
from dataclasses import dataclass
from captcha import load_captcha
@@ -53,7 +54,11 @@ async def pass_challenges(
if info.success: # noqa
return ChallengeOutcome(True, reason=(info.meta or {}).get("reason"))
# 2. передаем страницу в класс и ждем решения
await provider.solve(page, info) # noqa
try:
await provider.solve(page, info)
except Exception as e:
traceback.print_exc()
continue
else:
return ChallengeOutcome(
False,