From f1eae92df34a69bdd96a326ff88d7cd8d79fc25a Mon Sep 17 00:00:00 2001 From: Andrei Date: Sat, 5 Nov 2022 17:45:56 +0300 Subject: [PATCH] Update get_answer.py --- python3_anticaptcha/get_answer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python3_anticaptcha/get_answer.py b/python3_anticaptcha/get_answer.py index 67a5711..8f64e10 100644 --- a/python3_anticaptcha/get_answer.py +++ b/python3_anticaptcha/get_answer.py @@ -5,7 +5,7 @@ import aiohttp import requests from requests.adapters import HTTPAdapter -from python3_anticaptcha import get_result_url +from python3_anticaptcha.config import attempts_generator, get_result_url def get_sync_result(result_payload: dict, sleep_time: int, **kwargs) -> dict: @@ -16,7 +16,8 @@ def get_sync_result(result_payload: dict, sleep_time: int, **kwargs) -> dict: session.mount("https://", HTTPAdapter(max_retries=5)) session.verify = False - while True: + attempts = attempts_generator() + for attempt in attempts: captcha_response = session.post(get_result_url, json=result_payload, **kwargs).json() if captcha_response["errorId"] == 0: @@ -33,9 +34,10 @@ def get_sync_result(result_payload: dict, sleep_time: int, **kwargs) -> dict: async def get_async_result(result_payload: dict, sleep_time: int) -> dict: + attempts = attempts_generator() # Отправляем запрос на статус решения капчи. async with aiohttp.ClientSession() as session: - while True: + for attempt in attempts: async with session.post(get_result_url, json=result_payload) as resp: json_result = await resp.json() # Если нет ошибки - проверяем статус капчи