Skip to content

Commit 9e79d43

Browse files
committed
Update sio_captcha_instrument.py
1 parent 363106f commit 9e79d43

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

src/python3_capsolver/core/sio_captcha_instrument.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from requests.adapters import HTTPAdapter
99

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

34-
"""
35-
Sync part
36-
"""
37-
3834
def processing_captcha(self) -> dict:
3935
self.created_task_data = CaptchaResponseSer(**self.__create_task())
4036

@@ -157,6 +153,25 @@ def __body_file_processing(
157153
self.result.errorId = 1
158154
self.result.errorCode = self.CAPTCHA_UNSOLVABLE
159155

156+
@staticmethod
157+
def send_post_request(
158+
payload: Optional[dict] = None,
159+
session: requests.Session = requests.Session(),
160+
url_postfix: str = GET_BALANCE_POSTFIX,
161+
) -> dict:
162+
"""
163+
Function send SYNC request to service and wait for result
164+
"""
165+
try:
166+
resp = session.post(parse.urljoin(REQUEST_URL, url_postfix), json=payload)
167+
if resp.status_code == 200:
168+
return resp.json()
169+
else:
170+
raise ValueError(resp.raise_for_status())
171+
except Exception as error:
172+
logging.exception(error)
173+
raise
174+
160175
def _url_read(self, url: str, **kwargs):
161176
"""
162177
Method open links

0 commit comments

Comments
 (0)