diff --git a/src/python3_capsolver/core/sio_captcha_instrument.py b/src/python3_capsolver/core/sio_captcha_instrument.py index e7c47c3..539af36 100644 --- a/src/python3_capsolver/core/sio_captcha_instrument.py +++ b/src/python3_capsolver/core/sio_captcha_instrument.py @@ -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 @@ -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()) @@ -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