Skip to content

Commit

Permalink
Update sio_captcha_instrument.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDrang committed Dec 19, 2024
1 parent 363106f commit 9e79d43
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/python3_capsolver/core/sio_captcha_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from requests.adapters import HTTPAdapter

from .enum import SaveFormatsEnm, ResponseStatusEnm, EndpointPostfixEnm
from .const import RETRIES, VALID_STATUS_CODES
from .const import RETRIES, REQUEST_URL, VALID_STATUS_CODES, GET_BALANCE_POSTFIX
from .utils import attempts_generator
from .serializer import CaptchaResponseSer
from .captcha_instrument import CaptchaInstrument
Expand All @@ -31,10 +31,6 @@ def __init__(self, captcha_params: "CaptchaParams"):
self.session.mount("https://", HTTPAdapter(max_retries=RETRIES))
self.session.verify = False

"""
Sync part
"""

def processing_captcha(self) -> dict:
self.created_task_data = CaptchaResponseSer(**self.__create_task())

Expand Down Expand Up @@ -157,6 +153,25 @@ def __body_file_processing(
self.result.errorId = 1
self.result.errorCode = self.CAPTCHA_UNSOLVABLE

@staticmethod
def send_post_request(
payload: Optional[dict] = None,
session: requests.Session = requests.Session(),
url_postfix: str = GET_BALANCE_POSTFIX,
) -> dict:
"""
Function send SYNC request to service and wait for result
"""
try:
resp = session.post(parse.urljoin(REQUEST_URL, url_postfix), json=payload)
if resp.status_code == 200:
return resp.json()
else:
raise ValueError(resp.raise_for_status())
except Exception as error:
logging.exception(error)
raise

def _url_read(self, url: str, **kwargs):
"""
Method open links
Expand Down

0 comments on commit 9e79d43

Please sign in to comment.