fix: повышение стабильности обхода cf_turnstile
This commit is contained in:
1 parent
405e5ed2d0
commit
dc441e60ef
2 files changed
+17
-1
No files matched your search
@@ -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",
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user