chore: реализация детектора обязана установить stage
типо сигнал, что детект отработал корректно
This commit is contained in:
1 parent
23f8ee4360
commit
a0170c9754
2 files changed
+3
-1
No files matched your search
+2
-1
@@ -97,7 +97,7 @@ class AntiBotProvider:
|
|||||||
|
|
||||||
async def detect(self, page: Page) -> ChallengeInfo:
|
async def detect(self, page: Page) -> ChallengeInfo:
|
||||||
info = ChallengeInfo(
|
info = ChallengeInfo(
|
||||||
stage=Stage.INTERSTITIAL,
|
stage=None, # noqa
|
||||||
provider=self.provider,
|
provider=self.provider,
|
||||||
success_locator=self._success_locator,
|
success_locator=self._success_locator,
|
||||||
detect_locator=self._detect_locator,
|
detect_locator=self._detect_locator,
|
||||||
@@ -107,6 +107,7 @@ class AntiBotProvider:
|
|||||||
return info
|
return info
|
||||||
|
|
||||||
async def solve(self, page: Page, info: ChallengeInfo):
|
async def solve(self, page: Page, info: ChallengeInfo):
|
||||||
|
assert info.stage, "Unknown stage"
|
||||||
await self.solver.solve(page, info)
|
await self.solver.solve(page, info)
|
||||||
|
|
||||||
def configure(self, success_locator=None, detect_locator=None, **kwargs):
|
def configure(self, success_locator=None, detect_locator=None, **kwargs):
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ class ReCaptchaDetector(Detector):
|
|||||||
iframe = page.frame_locator("iframe[title='reCAPTCHA']")
|
iframe = page.frame_locator("iframe[title='reCAPTCHA']")
|
||||||
# ожидаем когда будет загружен чекбокс
|
# ожидаем когда будет загружен чекбокс
|
||||||
|
|
||||||
|
info.stage = Stage.INTERSTITIAL
|
||||||
checkbox = iframe.locator(checkbox_selector)
|
checkbox = iframe.locator(checkbox_selector)
|
||||||
try:
|
try:
|
||||||
await checkbox.wait_for(state="attached")
|
await checkbox.wait_for(state="attached")
|
||||||
|
|||||||
Reference in new issue
Block a user