python-rucaptcha 6.5.0__py3-none-any.whl → 6.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_rucaptcha/__version__.py +1 -1
- python_rucaptcha/altcha_captcha.py +152 -0
- python_rucaptcha/binance_captcha.py +155 -0
- python_rucaptcha/captchaai.py +160 -0
- python_rucaptcha/core/base.py +21 -0
- python_rucaptcha/core/captchaai.py +685 -0
- python_rucaptcha/core/data/__init__.py +1 -0
- python_rucaptcha/core/data/captchaai_legacy_profiles.json +19 -0
- python_rucaptcha/core/data/captchaai_profiles.json +26 -0
- python_rucaptcha/core/enums.py +23 -0
- python_rucaptcha/core/result_handler.py +0 -1
- python_rucaptcha/core/serializer.py +7 -3
- python_rucaptcha/vk_captcha.py +130 -25
- python_rucaptcha/yandex_smart_captcha.py +246 -0
- python_rucaptcha/yidun_captcha.py +171 -0
- python_rucaptcha-6.7.0.dist-info/METADATA +250 -0
- {python_rucaptcha-6.5.0.dist-info → python_rucaptcha-6.7.0.dist-info}/RECORD +20 -11
- {python_rucaptcha-6.5.0.dist-info → python_rucaptcha-6.7.0.dist-info}/WHEEL +1 -1
- python_rucaptcha-6.5.0.dist-info/METADATA +0 -108
- {python_rucaptcha-6.5.0.dist-info → python_rucaptcha-6.7.0.dist-info}/licenses/LICENSE +0 -0
- {python_rucaptcha-6.5.0.dist-info → python_rucaptcha-6.7.0.dist-info}/top_level.txt +0 -0
python_rucaptcha/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "6.
|
|
1
|
+
__version__ = "6.7.0"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
from typing import Union, Optional
|
|
2
|
+
|
|
3
|
+
from .core.base import BaseCaptcha
|
|
4
|
+
from .core.enums import AltchaEnm
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AltchaCaptcha(BaseCaptcha):
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
websiteURL: str,
|
|
11
|
+
method: Union[str, AltchaEnm] = AltchaEnm.AltchaTaskProxyless,
|
|
12
|
+
challengeURL: Optional[str] = None,
|
|
13
|
+
challengeJSON: Optional[str] = None,
|
|
14
|
+
proxyType: Optional[str] = None,
|
|
15
|
+
proxyAddress: Optional[str] = None,
|
|
16
|
+
proxyPort: Optional[int] = None,
|
|
17
|
+
proxyLogin: Optional[str] = None,
|
|
18
|
+
proxyPassword: Optional[str] = None,
|
|
19
|
+
*args,
|
|
20
|
+
**kwargs,
|
|
21
|
+
):
|
|
22
|
+
"""
|
|
23
|
+
The class is used to work with ALTCHA captcha.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
rucaptcha_key: User API key
|
|
27
|
+
websiteURL: Full URL of the captcha page
|
|
28
|
+
method: Captcha type
|
|
29
|
+
challengeURL: Full URL of the page that contains ALTCHA challenge
|
|
30
|
+
challengeJSON: JSON-encoded ALTCHA challenge data
|
|
31
|
+
proxyType: Proxy type (http, https, socks4, socks5)
|
|
32
|
+
proxyAddress: Proxy IP address or hostname
|
|
33
|
+
proxyPort: Proxy port
|
|
34
|
+
proxyLogin: Proxy login
|
|
35
|
+
proxyPassword: Proxy password
|
|
36
|
+
kwargs: Not required params for task creation request
|
|
37
|
+
|
|
38
|
+
Examples:
|
|
39
|
+
>>> AltchaCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
|
|
40
|
+
... websiteURL="https://example.com",
|
|
41
|
+
... challengeURL="https://example.com/altcha/challenge.js",
|
|
42
|
+
... method=AltchaEnm.AltchaTaskProxyless.value,
|
|
43
|
+
... ).captcha_handler()
|
|
44
|
+
{
|
|
45
|
+
"errorId":0,
|
|
46
|
+
"status":"ready",
|
|
47
|
+
"solution":{
|
|
48
|
+
"token":"..."
|
|
49
|
+
},
|
|
50
|
+
"cost":"0.00145",
|
|
51
|
+
"ip":"1.2.3.4",
|
|
52
|
+
"createTime":1692863536,
|
|
53
|
+
"endTime":1692863556,
|
|
54
|
+
"solveCount":1,
|
|
55
|
+
"taskId": 73243152973,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
>>> await AltchaCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
|
|
59
|
+
... websiteURL="https://example.com",
|
|
60
|
+
... challengeJSON='{"挑战数据"}',
|
|
61
|
+
... method=AltchaEnm.AltchaTask.value,
|
|
62
|
+
... proxyType="http",
|
|
63
|
+
... proxyAddress="1.2.3.4",
|
|
64
|
+
... proxyPort=8080,
|
|
65
|
+
... ).aio_captcha_handler()
|
|
66
|
+
{
|
|
67
|
+
"errorId":0,
|
|
68
|
+
"status":"ready",
|
|
69
|
+
"solution":{
|
|
70
|
+
"token":"..."
|
|
71
|
+
},
|
|
72
|
+
"cost":"0.00145",
|
|
73
|
+
"ip":"1.2.3.4",
|
|
74
|
+
"createTime":1692863536,
|
|
75
|
+
"endTime":1692863556,
|
|
76
|
+
"solveCount":1,
|
|
77
|
+
"taskId": 73243152973,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
Dict with full server response
|
|
82
|
+
|
|
83
|
+
Notes:
|
|
84
|
+
https://rucaptcha.com/api-docs/altcha
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
super().__init__(method=method, *args, **kwargs)
|
|
88
|
+
|
|
89
|
+
# XOR validation: exactly one of challengeURL or challengeJSON must be provided
|
|
90
|
+
if not (bool(challengeURL) ^ bool(challengeJSON)):
|
|
91
|
+
raise ValueError(
|
|
92
|
+
"Exactly one of 'challengeURL' or 'challengeJSON' must be provided, not both or neither"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Validate method
|
|
96
|
+
if method not in AltchaEnm.list_values():
|
|
97
|
+
raise ValueError(f"Invalid method parameter set, available - {AltchaEnm.list_values()}")
|
|
98
|
+
|
|
99
|
+
# Build task payload
|
|
100
|
+
task_data = {"websiteURL": websiteURL}
|
|
101
|
+
|
|
102
|
+
if challengeURL:
|
|
103
|
+
task_data["challengeURL"] = challengeURL
|
|
104
|
+
|
|
105
|
+
if challengeJSON:
|
|
106
|
+
task_data["challengeJSON"] = challengeJSON
|
|
107
|
+
|
|
108
|
+
# Add proxy params only for non-proxyless methods
|
|
109
|
+
if method == AltchaEnm.AltchaTask.value:
|
|
110
|
+
if not all([proxyType, proxyAddress, proxyPort]):
|
|
111
|
+
raise ValueError(
|
|
112
|
+
"Proxy parameters (proxyType, proxyAddress, proxyPort) are required for AltchaTask"
|
|
113
|
+
)
|
|
114
|
+
task_data.update(
|
|
115
|
+
{
|
|
116
|
+
"proxyType": proxyType,
|
|
117
|
+
"proxyAddress": proxyAddress,
|
|
118
|
+
"proxyPort": proxyPort,
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
if proxyLogin and proxyPassword:
|
|
122
|
+
task_data["proxyLogin"] = proxyLogin
|
|
123
|
+
task_data["proxyPassword"] = proxyPassword
|
|
124
|
+
|
|
125
|
+
self.create_task_payload["task"].update(task_data)
|
|
126
|
+
|
|
127
|
+
def captcha_handler(self, **kwargs) -> dict:
|
|
128
|
+
"""
|
|
129
|
+
Sync solving method
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
kwargs: Parameters for the `requests` library
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Dict with full server response
|
|
136
|
+
|
|
137
|
+
Notes:
|
|
138
|
+
Check class docstirng for more info
|
|
139
|
+
"""
|
|
140
|
+
return self._processing_response(**kwargs)
|
|
141
|
+
|
|
142
|
+
async def aio_captcha_handler(self) -> dict:
|
|
143
|
+
"""
|
|
144
|
+
Async solving method
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Dict with full server response
|
|
148
|
+
|
|
149
|
+
Notes:
|
|
150
|
+
Check class docstirng for more info
|
|
151
|
+
"""
|
|
152
|
+
return await self._aio_processing_response()
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
from typing import Union, Optional
|
|
2
|
+
|
|
3
|
+
from .core.base import BaseCaptcha
|
|
4
|
+
from .core.enums import BinanceCaptchaEnm
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BinanceCaptcha(BaseCaptcha):
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
websiteURL: str,
|
|
11
|
+
websiteKey: str,
|
|
12
|
+
validateId: str,
|
|
13
|
+
method: Union[str, BinanceCaptchaEnm] = BinanceCaptchaEnm.BinanceTaskProxyless,
|
|
14
|
+
userAgent: Optional[str] = None,
|
|
15
|
+
proxyType: Optional[str] = None,
|
|
16
|
+
proxyAddress: Optional[str] = None,
|
|
17
|
+
proxyPort: Optional[int] = None,
|
|
18
|
+
proxyLogin: Optional[str] = None,
|
|
19
|
+
proxyPassword: Optional[str] = None,
|
|
20
|
+
*args,
|
|
21
|
+
**kwargs,
|
|
22
|
+
):
|
|
23
|
+
"""
|
|
24
|
+
The class is used to work with Binance CAPTCHA.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
rucaptcha_key: User API key
|
|
28
|
+
websiteURL: Full URL of the page where the captcha is loaded
|
|
29
|
+
websiteKey: Value of bizId, bizType, or bizCode from page requests
|
|
30
|
+
validateId: Dynamic value of validateId, securityId, or securityCheckResponseValidateId
|
|
31
|
+
method: Captcha type
|
|
32
|
+
userAgent: User-Agent string to be used when solving the captcha
|
|
33
|
+
proxyType: Proxy type (http, https, socks4, socks5)
|
|
34
|
+
proxyAddress: Proxy IP address or hostname
|
|
35
|
+
proxyPort: Proxy port
|
|
36
|
+
proxyLogin: Proxy login
|
|
37
|
+
proxyPassword: Proxy password
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
>>> BinanceCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
|
|
41
|
+
... websiteURL="https://example.com/page-with-binance",
|
|
42
|
+
... websiteKey="login",
|
|
43
|
+
... validateId="cb0bfefa598...e54ecd57b",
|
|
44
|
+
... userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
45
|
+
... "(KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
|
|
46
|
+
... method=BinanceCaptchaEnm.BinanceTaskProxyless.value,
|
|
47
|
+
... ).captcha_handler()
|
|
48
|
+
{
|
|
49
|
+
"errorId":0,
|
|
50
|
+
"status":"ready",
|
|
51
|
+
"solution":{
|
|
52
|
+
"token":"captcha#09ba4905a79f44f...kc99maS943qIsquNP9D77",
|
|
53
|
+
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
|
54
|
+
},
|
|
55
|
+
"cost":"0.00299",
|
|
56
|
+
"ip":"1.2.3.4",
|
|
57
|
+
"createTime":1692863536,
|
|
58
|
+
"endTime":1692863556,
|
|
59
|
+
"solveCount":1,
|
|
60
|
+
"taskId": 73243152973,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
>>> await BinanceCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
|
|
64
|
+
... websiteURL="https://example.com/page-with-binance",
|
|
65
|
+
... websiteKey="login",
|
|
66
|
+
... validateId="cb0bfefa598...e54ecd57b",
|
|
67
|
+
... method=BinanceCaptchaEnm.BinanceTask.value,
|
|
68
|
+
... proxyType="http",
|
|
69
|
+
... proxyAddress="1.2.3.4",
|
|
70
|
+
... proxyPort=8080,
|
|
71
|
+
... ).aio_captcha_handler()
|
|
72
|
+
{
|
|
73
|
+
"errorId":0,
|
|
74
|
+
"status":"ready",
|
|
75
|
+
"solution":{
|
|
76
|
+
"token":"captcha#09ba4905a79f44f...kc99maS943qIsquNP9D77",
|
|
77
|
+
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
|
|
78
|
+
},
|
|
79
|
+
"cost":"0.00299",
|
|
80
|
+
"ip":"1.2.3.4",
|
|
81
|
+
"createTime":1692863536,
|
|
82
|
+
"endTime":1692863556,
|
|
83
|
+
"solveCount":1,
|
|
84
|
+
"taskId": 73243152973,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
Dict with full server response
|
|
89
|
+
|
|
90
|
+
Notes:
|
|
91
|
+
https://2captcha.com/api-docs/binance-captcha
|
|
92
|
+
|
|
93
|
+
https://rucaptcha.com/api-docs/binance-captcha
|
|
94
|
+
"""
|
|
95
|
+
super().__init__(method=method, *args, **kwargs)
|
|
96
|
+
|
|
97
|
+
# Validate method
|
|
98
|
+
if method not in BinanceCaptchaEnm.list_values():
|
|
99
|
+
raise ValueError(f"Invalid method parameter set, available - {BinanceCaptchaEnm.list_values()}")
|
|
100
|
+
|
|
101
|
+
# Build task payload
|
|
102
|
+
task_data = {
|
|
103
|
+
"websiteURL": websiteURL,
|
|
104
|
+
"websiteKey": websiteKey,
|
|
105
|
+
"validateId": validateId,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if userAgent:
|
|
109
|
+
task_data["userAgent"] = userAgent
|
|
110
|
+
|
|
111
|
+
# Add proxy params only for non-proxyless methods
|
|
112
|
+
if method == BinanceCaptchaEnm.BinanceTask.value:
|
|
113
|
+
if not all([proxyType, proxyAddress, proxyPort]):
|
|
114
|
+
raise ValueError(
|
|
115
|
+
"Proxy parameters (proxyType, proxyAddress, proxyPort) are required for BinanceTask"
|
|
116
|
+
)
|
|
117
|
+
task_data.update(
|
|
118
|
+
{
|
|
119
|
+
"proxyType": proxyType,
|
|
120
|
+
"proxyAddress": proxyAddress,
|
|
121
|
+
"proxyPort": proxyPort,
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
if proxyLogin and proxyPassword:
|
|
125
|
+
task_data["proxyLogin"] = proxyLogin
|
|
126
|
+
task_data["proxyPassword"] = proxyPassword
|
|
127
|
+
|
|
128
|
+
self.create_task_payload["task"].update(task_data)
|
|
129
|
+
|
|
130
|
+
def captcha_handler(self, **kwargs) -> dict:
|
|
131
|
+
"""
|
|
132
|
+
Sync solving method
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
kwargs: Parameters for the `requests` library
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
Dict with full server response
|
|
139
|
+
|
|
140
|
+
Notes:
|
|
141
|
+
Check class docstirng for more info
|
|
142
|
+
"""
|
|
143
|
+
return self._processing_response(**kwargs)
|
|
144
|
+
|
|
145
|
+
async def aio_captcha_handler(self) -> dict:
|
|
146
|
+
"""
|
|
147
|
+
Async solving method
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Dict with full server response
|
|
151
|
+
|
|
152
|
+
Notes:
|
|
153
|
+
Check class docstirng for more info
|
|
154
|
+
"""
|
|
155
|
+
return await self._aio_processing_response()
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""Native, future-compatible CaptchaAI classic API client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Mapping
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
from requests.adapters import HTTPAdapter
|
|
9
|
+
|
|
10
|
+
from .core import captchaai as transport
|
|
11
|
+
from .core.enums import ServiceEnm
|
|
12
|
+
from .core.config import RETRIES
|
|
13
|
+
from .core.serializer import CaptchaOptionsSer
|
|
14
|
+
|
|
15
|
+
CaptchaAIFile = transport.CaptchaAIFile
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CaptchaAI:
|
|
19
|
+
"""Client for CaptchaAI's classic multipart API.
|
|
20
|
+
|
|
21
|
+
A packaged profile can validate a documented method contract. Omitting the
|
|
22
|
+
profile allows provider-native parameters for methods not yet represented
|
|
23
|
+
in the package metadata.
|
|
24
|
+
|
|
25
|
+
Attributes:
|
|
26
|
+
key: CaptchaAI API key used for requests.
|
|
27
|
+
method: Provider method submitted by the client.
|
|
28
|
+
params: Provider-native scalar parameters.
|
|
29
|
+
files: Multipart file parts keyed by provider field name.
|
|
30
|
+
profile: Optional packaged profile name.
|
|
31
|
+
poll: Whether to poll for a result after submission.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
rucaptcha_key: str,
|
|
37
|
+
method: str | None = None,
|
|
38
|
+
params: Mapping[str, Any] | None = None,
|
|
39
|
+
*,
|
|
40
|
+
files: Mapping[str, CaptchaAIFile] | None = None,
|
|
41
|
+
profile: str | None = None,
|
|
42
|
+
poll: bool | None = None,
|
|
43
|
+
sleep_time: int = 10,
|
|
44
|
+
):
|
|
45
|
+
"""Create a client for one CaptchaAI method.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
rucaptcha_key: API key used for CaptchaAI requests.
|
|
49
|
+
method: Provider-native method name. Required unless ``profile``
|
|
50
|
+
supplies the method.
|
|
51
|
+
params: Provider-native scalar parameters.
|
|
52
|
+
files: Multipart file parts keyed by provider field name.
|
|
53
|
+
profile: Optional packaged profile used for validation and defaults.
|
|
54
|
+
poll: Whether to poll after submission. If omitted, the profile
|
|
55
|
+
determines the default and native methods poll by default.
|
|
56
|
+
sleep_time: Seconds between result polls.
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
ValueError: If neither ``method`` nor ``profile`` is supplied.
|
|
60
|
+
"""
|
|
61
|
+
if method is None:
|
|
62
|
+
if profile is None:
|
|
63
|
+
raise ValueError("CaptchaAI requires a method or a documented profile")
|
|
64
|
+
method = transport.profile_method(profile)
|
|
65
|
+
|
|
66
|
+
self.key = rucaptcha_key
|
|
67
|
+
self.method = method
|
|
68
|
+
self.params = dict(params or {})
|
|
69
|
+
self.files = dict(files or {})
|
|
70
|
+
self.profile = profile
|
|
71
|
+
self.poll = poll
|
|
72
|
+
self.options = CaptchaOptionsSer(sleep_time=sleep_time, service_type=ServiceEnm.CAPTCHAAI)
|
|
73
|
+
self.options.urls_set()
|
|
74
|
+
self.session = requests.Session()
|
|
75
|
+
self.session.mount("http://", HTTPAdapter(max_retries=RETRIES))
|
|
76
|
+
self.session.mount("https://", HTTPAdapter(max_retries=RETRIES))
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def profiles(cls) -> tuple[str, ...]:
|
|
80
|
+
"""List the packaged CaptchaAI profile names.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
Profile names available for declarative validation.
|
|
84
|
+
"""
|
|
85
|
+
return transport.profiles()
|
|
86
|
+
|
|
87
|
+
def captcha_handler(self) -> dict[str, Any]:
|
|
88
|
+
"""Submit the configured method and optionally poll for its result.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
A normalized result mapping containing either the solution or an
|
|
92
|
+
error description.
|
|
93
|
+
"""
|
|
94
|
+
return transport.solve_native(
|
|
95
|
+
key=self.key,
|
|
96
|
+
method=self.method,
|
|
97
|
+
params=self.params,
|
|
98
|
+
files=self.files,
|
|
99
|
+
profile=self.profile,
|
|
100
|
+
poll=self.poll,
|
|
101
|
+
url_request=self.options.url_request,
|
|
102
|
+
url_response=self.options.url_response,
|
|
103
|
+
sleep_time=self.options.sleep_time,
|
|
104
|
+
session=self.session,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
async def aio_captcha_handler(self) -> dict[str, Any]:
|
|
108
|
+
"""Asynchronously submit the method and optionally poll for its result.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
A normalized result mapping containing either the solution or an
|
|
112
|
+
error description.
|
|
113
|
+
"""
|
|
114
|
+
return await transport.aio_solve_native(
|
|
115
|
+
key=self.key,
|
|
116
|
+
method=self.method,
|
|
117
|
+
params=self.params,
|
|
118
|
+
files=self.files,
|
|
119
|
+
profile=self.profile,
|
|
120
|
+
poll=self.poll,
|
|
121
|
+
url_request=self.options.url_request,
|
|
122
|
+
url_response=self.options.url_response,
|
|
123
|
+
sleep_time=self.options.sleep_time,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def get_balance(self) -> dict[str, Any]:
|
|
127
|
+
"""Fetch the account balance through the CaptchaAI control API.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
The provider response with the balance value when successful, or
|
|
131
|
+
the normalized error mapping returned by the transport.
|
|
132
|
+
"""
|
|
133
|
+
return transport.control(self.key, "balance", self.options.url_response, session=self.session)
|
|
134
|
+
|
|
135
|
+
async def aio_get_balance(self) -> dict[str, Any]:
|
|
136
|
+
"""Asynchronously fetch the account balance.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
The provider response with the balance value when successful, or
|
|
140
|
+
the normalized error mapping returned by the transport.
|
|
141
|
+
"""
|
|
142
|
+
return await transport.aio_control(self.key, "balance", self.options.url_response)
|
|
143
|
+
|
|
144
|
+
def get_threads_info(self) -> dict[str, Any]:
|
|
145
|
+
"""Fetch total and active thread information.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
The provider response with thread information, or the normalized
|
|
149
|
+
error mapping returned by the transport.
|
|
150
|
+
"""
|
|
151
|
+
return transport.control(self.key, "threads_info", self.options.url_response, session=self.session)
|
|
152
|
+
|
|
153
|
+
async def aio_get_threads_info(self) -> dict[str, Any]:
|
|
154
|
+
"""Asynchronously fetch total and active thread information.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
The provider response with thread information, or the normalized
|
|
158
|
+
error mapping returned by the transport.
|
|
159
|
+
"""
|
|
160
|
+
return await transport.aio_control(self.key, "threads_info", self.options.url_response)
|
python_rucaptcha/core/base.py
CHANGED
|
@@ -82,6 +82,17 @@ class BaseCaptcha:
|
|
|
82
82
|
Method processing captcha solving task creation result
|
|
83
83
|
:param kwargs: additional params for Requests library
|
|
84
84
|
"""
|
|
85
|
+
# CaptchaAI speaks the classic in.php/res.php API, not the JSON createTask API.
|
|
86
|
+
if self.params.service_type == ServiceEnm.CAPTCHAAI.value:
|
|
87
|
+
from . import captchaai
|
|
88
|
+
|
|
89
|
+
return captchaai.solve(
|
|
90
|
+
create_task_payload=self.create_task_payload,
|
|
91
|
+
url_request=self.params.url_request,
|
|
92
|
+
url_response=self.params.url_response,
|
|
93
|
+
sleep_time=self.params.sleep_time,
|
|
94
|
+
session=self.session,
|
|
95
|
+
)
|
|
85
96
|
try:
|
|
86
97
|
response = GetTaskResultResponseSer(
|
|
87
98
|
**self.session.post(self.params.url_request, json=self.create_task_payload, **kwargs).json()
|
|
@@ -126,6 +137,16 @@ class BaseCaptcha:
|
|
|
126
137
|
"""
|
|
127
138
|
Method processing async captcha solving task creation result
|
|
128
139
|
"""
|
|
140
|
+
# CaptchaAI speaks the classic in.php/res.php API, not the JSON createTask API.
|
|
141
|
+
if self.params.service_type == ServiceEnm.CAPTCHAAI.value:
|
|
142
|
+
from . import captchaai
|
|
143
|
+
|
|
144
|
+
return await captchaai.aio_solve(
|
|
145
|
+
create_task_payload=self.create_task_payload,
|
|
146
|
+
url_request=self.params.url_request,
|
|
147
|
+
url_response=self.params.url_response,
|
|
148
|
+
sleep_time=self.params.sleep_time,
|
|
149
|
+
)
|
|
129
150
|
try:
|
|
130
151
|
# make async or sync request
|
|
131
152
|
response = await self.__aio_create_task()
|