python3-capsolver 0.9.4__py3-none-any.whl → 1.0.1__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.
- python3_capsolver/__version__.py +1 -1
- python3_capsolver/aws_waf.py +122 -95
- python3_capsolver/cloudflare.py +113 -96
- python3_capsolver/control.py +31 -29
- python3_capsolver/core/aio_captcha_instrument.py +109 -0
- python3_capsolver/core/base.py +49 -194
- python3_capsolver/core/captcha_instrument.py +145 -0
- python3_capsolver/core/const.py +27 -0
- python3_capsolver/core/context_instr.py +25 -0
- python3_capsolver/core/enum.py +21 -76
- python3_capsolver/core/serializer.py +35 -128
- python3_capsolver/core/sio_captcha_instrument.py +116 -0
- python3_capsolver/core/{config.py → utils.py} +1 -10
- python3_capsolver/datadome_slider.py +56 -84
- python3_capsolver/friendly_captcha.py +105 -0
- python3_capsolver/gee_test.py +58 -90
- python3_capsolver/image_to_text.py +86 -116
- python3_capsolver/mt_captcha.py +49 -108
- python3_capsolver/recaptcha.py +65 -129
- python3_capsolver/vision_engine.py +102 -0
- python3_capsolver/yandex.py +73 -0
- {python3_capsolver-0.9.4.dist-info → python3_capsolver-1.0.1.dist-info}/METADATA +12 -12
- python3_capsolver-1.0.1.dist-info/RECORD +28 -0
- {python3_capsolver-0.9.4.dist-info → python3_capsolver-1.0.1.dist-info}/WHEEL +1 -1
- python3_capsolver/akamai.py +0 -192
- python3_capsolver/binance.py +0 -112
- python3_capsolver/cyber_si_ara.py +0 -128
- python3_capsolver/fun_captcha.py +0 -251
- python3_capsolver/hcaptcha.py +0 -197
- python3_capsolver/imperva.py +0 -120
- python3_capsolver-0.9.4.dist-info/RECORD +0 -26
- {python3_capsolver-0.9.4.dist-info → python3_capsolver-1.0.1.dist-info}/LICENSE +0 -0
- {python3_capsolver-0.9.4.dist-info → python3_capsolver-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
from .core.base import CaptchaParams
|
|
4
|
+
from .core.enum import CaptchaTypeEnm
|
|
5
|
+
|
|
6
|
+
__all__ = ("FriendlyCaptcha",)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class FriendlyCaptcha(CaptchaParams):
|
|
10
|
+
"""
|
|
11
|
+
The class is used to work with Capsolver FriendlyCaptchaTaskProxyless methods.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
api_key: Capsolver API key
|
|
15
|
+
captcha_type: Captcha type name, like ``FriendlyCaptchaTaskProxyless`` and etc.
|
|
16
|
+
kwargs: additional params for client, like captcha waiting time
|
|
17
|
+
available keys:
|
|
18
|
+
- sleep_time: int - captcha solution waintig time in sec
|
|
19
|
+
- request_url: str - API address for sending requests,
|
|
20
|
+
else official will be used
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
>>> from python3_capsolver.core.enum import CaptchaTypeEnm
|
|
24
|
+
>>> from python3_capsolver.friendly_captcha import FriendlyCaptcha
|
|
25
|
+
>>> FriendlyCaptcha(api_key="CAP-XXXXX",
|
|
26
|
+
... captcha_type=CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
|
|
27
|
+
... ).captcha_handler(task_payload={
|
|
28
|
+
... "websiteURL": "https://www.yourwebsite.com",
|
|
29
|
+
... "proxy": "ip:port:user:pass"
|
|
30
|
+
... })
|
|
31
|
+
{
|
|
32
|
+
"errorId":0,
|
|
33
|
+
"errorCode":"None",
|
|
34
|
+
"errorDescription":"None",
|
|
35
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
36
|
+
"status":"ready",
|
|
37
|
+
"solution":{
|
|
38
|
+
"cookies": "cf_clearance=_VPxxxx",
|
|
39
|
+
"headers": {
|
|
40
|
+
"sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
|
|
41
|
+
"sec-ch-ua-platform": "\"Windows\"",
|
|
42
|
+
"accept": "text/html,axxxx",
|
|
43
|
+
"User-Agent": "Mozilla/5.0xxxx",
|
|
44
|
+
"sec-ch-ua-mobile": "?0",
|
|
45
|
+
"sec-fetch-user": "?1",
|
|
46
|
+
"referer": "https://www.yourwebsite.com",
|
|
47
|
+
"Sec-Fetch-Dest": "document",
|
|
48
|
+
"Sec-Fetch-Mode": "navigate",
|
|
49
|
+
"Sec-Fetch-Site": "same-origin",
|
|
50
|
+
"accept-language": "en",
|
|
51
|
+
},
|
|
52
|
+
"page_url": "https://www.yourwebsite.com",
|
|
53
|
+
"proxy": "your proxyxxxx",
|
|
54
|
+
"token": "_VPCTZXP5bhinxxxx"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
>>> import asyncio
|
|
59
|
+
>>> from python3_capsolver.core.enum import CaptchaTypeEnm
|
|
60
|
+
>>> from python3_capsolver.friendly_captcha import FriendlyCaptcha
|
|
61
|
+
>>> asyncio.run(FriendlyCaptcha(api_key="CAP-XXXXX",
|
|
62
|
+
... captcha_type=CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
|
|
63
|
+
... ).aio_captcha_handler(task_payload={
|
|
64
|
+
... "websiteURL": "https://www.yourwebsite.com",
|
|
65
|
+
... "proxy": "ip:port:user:pass"
|
|
66
|
+
... }))
|
|
67
|
+
{
|
|
68
|
+
"errorId":0,
|
|
69
|
+
"errorCode":"None",
|
|
70
|
+
"errorDescription":"None",
|
|
71
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
72
|
+
"status":"ready",
|
|
73
|
+
"solution":{
|
|
74
|
+
"cookies": "cf_clearance=_VPxxxx",
|
|
75
|
+
"headers": {
|
|
76
|
+
"sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
|
|
77
|
+
"sec-ch-ua-platform": "\"Windows\"",
|
|
78
|
+
"accept": "text/html,axxxx",
|
|
79
|
+
"User-Agent": "Mozilla/5.0xxxx",
|
|
80
|
+
"sec-ch-ua-mobile": "?0",
|
|
81
|
+
"sec-fetch-user": "?1",
|
|
82
|
+
"referer": "https://www.yourwebsite.com",
|
|
83
|
+
"Sec-Fetch-Dest": "document",
|
|
84
|
+
"Sec-Fetch-Mode": "navigate",
|
|
85
|
+
"Sec-Fetch-Site": "same-origin",
|
|
86
|
+
"accept-language": "en",
|
|
87
|
+
},
|
|
88
|
+
"page_url": "https://www.yourwebsite.com",
|
|
89
|
+
"proxy": "your proxyxxxx",
|
|
90
|
+
"token": "_VPCTZXP5bhinxxxx"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Notes:
|
|
95
|
+
https://docs.capsolver.com/en/guide/captcha/FriendlyCaptcha/
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
def __init__(
|
|
99
|
+
self,
|
|
100
|
+
api_key: str,
|
|
101
|
+
captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
|
|
102
|
+
**kwargs,
|
|
103
|
+
):
|
|
104
|
+
|
|
105
|
+
super().__init__(api_key=api_key, captcha_type=captcha_type, **kwargs)
|
python3_capsolver/gee_test.py
CHANGED
|
@@ -1,108 +1,76 @@
|
|
|
1
1
|
from typing import Union
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from python3_capsolver.core.serializer import GeeTestSer, CaptchaResponseSer
|
|
3
|
+
from .core.base import CaptchaParams
|
|
4
|
+
from .core.enum import CaptchaTypeEnm
|
|
6
5
|
|
|
6
|
+
__all__ = ("GeeTest",)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
class GeeTest(CaptchaParams):
|
|
9
10
|
"""
|
|
10
|
-
The class is used to work with Capsolver
|
|
11
|
+
The class is used to work with Capsolver GeeTestTaskProxyLess methods.
|
|
11
12
|
|
|
12
13
|
Args:
|
|
13
14
|
api_key: Capsolver API key
|
|
14
15
|
captcha_type: Captcha type name, like ``GeeTestTaskProxyLess`` and etc.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
kwargs: additional params for client, like captcha waiting time
|
|
17
|
+
available keys:
|
|
18
|
+
- sleep_time: int - captcha solution waintig time in sec
|
|
19
|
+
- request_url: str - API address for sending requests,
|
|
20
|
+
else official will be used
|
|
18
21
|
|
|
19
22
|
Examples:
|
|
20
|
-
>>>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
...
|
|
25
|
-
...
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...
|
|
51
|
-
...
|
|
52
|
-
...
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Returns:
|
|
65
|
-
CaptchaResponseSer model with full server response
|
|
23
|
+
>>> from python3_capsolver.core.enum import CaptchaTypeEnm
|
|
24
|
+
>>> from python3_capsolver.gee_test import GeeTest
|
|
25
|
+
|
|
26
|
+
>>> GeeTest(api_key="CAP-XXXXX",
|
|
27
|
+
... captcha_type=CaptchaTypeEnm.GeeTestTaskProxyLess,
|
|
28
|
+
... ).captcha_handler(task_payload={
|
|
29
|
+
... "websiteURL": "https://www.geetest.com/en/demo",
|
|
30
|
+
... "gt": "022397c99c9f646f6477822485f30404",
|
|
31
|
+
... "challenge": "12345678abc90123d45678ef90123a456b",
|
|
32
|
+
... })
|
|
33
|
+
{
|
|
34
|
+
"errorId":0,
|
|
35
|
+
"errorCode":"None",
|
|
36
|
+
"errorDescription":"None",
|
|
37
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
38
|
+
"status":"ready",
|
|
39
|
+
"solution":{
|
|
40
|
+
"challenge": "xxx",
|
|
41
|
+
"validate": "xxx"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
>>> import asyncio
|
|
46
|
+
>>> from python3_capsolver.core.enum import CaptchaTypeEnm
|
|
47
|
+
>>> from python3_capsolver.gee_test import GeeTest
|
|
48
|
+
|
|
49
|
+
>>> asyncio.run(GeeTest(api_key="CAP-XXXXX",
|
|
50
|
+
... captcha_type=CaptchaTypeEnm.GeeTestTaskProxyLess,
|
|
51
|
+
... ).aio_captcha_handler(task_payload={
|
|
52
|
+
... "websiteURL": "https://www.geetest.com/en/demo",
|
|
53
|
+
... "gt": "022397c99c9f646f6477822485f30404",
|
|
54
|
+
... "challenge": "12345678abc90123d45678ef90123a456b",
|
|
55
|
+
... }))
|
|
56
|
+
{
|
|
57
|
+
"errorId":0,
|
|
58
|
+
"errorCode":"None",
|
|
59
|
+
"errorDescription":"None",
|
|
60
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
61
|
+
"status":"ready",
|
|
62
|
+
"solution":{
|
|
63
|
+
"challenge": "xxx",
|
|
64
|
+
"validate": "xxx"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
66
67
|
|
|
67
68
|
Notes:
|
|
68
|
-
https://docs.capsolver.com/guide/captcha/Geetest
|
|
69
|
+
https://docs.capsolver.com/en/guide/captcha/Geetest/
|
|
69
70
|
"""
|
|
70
71
|
|
|
71
72
|
def __init__(
|
|
72
|
-
self,
|
|
73
|
+
self, api_key: str, captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.GeeTestTaskProxyLess, **kwargs
|
|
73
74
|
):
|
|
74
|
-
super().__init__(*args, **kwargs)
|
|
75
|
-
|
|
76
|
-
if captcha_type in GeeTestCaptchaTypeEnm.list():
|
|
77
|
-
self.task_params = GeeTestSer(**locals()).dict()
|
|
78
|
-
else:
|
|
79
|
-
raise ValueError(
|
|
80
|
-
f"""Invalid `captcha_type` parameter set for `{self.__class__.__name__}`,
|
|
81
|
-
available - {GeeTestCaptchaTypeEnm.list()}"""
|
|
82
|
-
)
|
|
83
|
-
for key in kwargs:
|
|
84
|
-
self.task_params.update({key: kwargs[key]})
|
|
85
|
-
|
|
86
|
-
def captcha_handler(self) -> CaptchaResponseSer:
|
|
87
|
-
"""
|
|
88
|
-
Sync solving method
|
|
89
|
-
|
|
90
|
-
Returns:
|
|
91
|
-
CaptchaResponseSer model with full service response
|
|
92
|
-
|
|
93
|
-
Notes:
|
|
94
|
-
Check class docstring for more info
|
|
95
|
-
"""
|
|
96
|
-
return self._processing_captcha(create_params=self.task_params)
|
|
97
|
-
|
|
98
|
-
async def aio_captcha_handler(self) -> CaptchaResponseSer:
|
|
99
|
-
"""
|
|
100
|
-
Async solving method
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
CaptchaResponseSer model with full service response
|
|
104
75
|
|
|
105
|
-
|
|
106
|
-
Check class docstring for more info
|
|
107
|
-
"""
|
|
108
|
-
return await self._aio_processing_captcha(create_params=self.task_params)
|
|
76
|
+
super().__init__(api_key=api_key, captcha_type=captcha_type, **kwargs)
|
|
@@ -1,151 +1,121 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Any, Dict
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from python3_capsolver.core.serializer import TaskSer, CaptchaResponseSer
|
|
3
|
+
from .core.base import CaptchaParams
|
|
4
|
+
from .core.enum import CaptchaTypeEnm
|
|
6
5
|
|
|
6
|
+
__all__ = ("ImageToText",)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
class ImageToText(CaptchaParams):
|
|
9
10
|
"""
|
|
10
|
-
The class is used to work with Capsolver Image captcha solving
|
|
11
|
+
The class is used to work with Capsolver Image captcha solving method.
|
|
11
12
|
|
|
12
13
|
Args:
|
|
13
14
|
api_key: Capsolver API key
|
|
14
|
-
|
|
15
|
+
kwargs: additional params for client, like captcha waiting time
|
|
16
|
+
available keys:
|
|
17
|
+
- sleep_time: int - captcha solution waintig time in sec
|
|
18
|
+
- request_url: str - API address for sending requests,
|
|
19
|
+
else official will be used
|
|
15
20
|
|
|
16
21
|
Examples:
|
|
17
|
-
>>>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
>>>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
...
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
>>>
|
|
62
|
-
|
|
63
|
-
...
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
errorCode=None,
|
|
78
|
-
errorDescription=None,
|
|
79
|
-
taskId='73bdcd28-6c77-4414-8....',
|
|
80
|
-
status=<ResponseStatusEnm.Ready: 'ready'>,
|
|
81
|
-
solution={'confidence': 0.9585, 'text': 'gcphjd'}
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
>>> with open('some_image.jpeg', 'rb') as img_file:
|
|
85
|
-
... img_data = img_file.read()
|
|
86
|
-
>>> body = base64.b64encode(img_data).decode("utf-8")
|
|
87
|
-
>>> with ImageToText(api_key="CAI-12345....") as image_to_text_inst:
|
|
88
|
-
... await image_to_text_inst.aio_captcha_handler(body=body)
|
|
89
|
-
CaptchaResponseSer(errorId=0,
|
|
90
|
-
errorCode=None,
|
|
91
|
-
errorDescription=None,
|
|
92
|
-
taskId='73bdcd28-6c77-4414-8....',
|
|
93
|
-
status=<ResponseStatusEnm.Ready: 'ready'>,
|
|
94
|
-
solution={'confidence': 0.9585, 'text': 'gcphjd'}
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
Returns:
|
|
98
|
-
CaptchaResponseSer model with full server response
|
|
22
|
+
>>> from python3_capsolver.image_to_text import ImageToText
|
|
23
|
+
>>> from python3_capsolver.core.captcha_instrument import FileInstrument
|
|
24
|
+
|
|
25
|
+
>>> body = FileInstrument().file_processing(captcha_file="captcha_example.jpeg")
|
|
26
|
+
>>> ImageToText(api_key="CAI-12345....").captcha_handler(
|
|
27
|
+
... task_payload={"body": body, "module": "common"}
|
|
28
|
+
... )
|
|
29
|
+
{
|
|
30
|
+
"errorId":0,
|
|
31
|
+
"errorCode":"None",
|
|
32
|
+
"errorDescription":"None",
|
|
33
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
34
|
+
"status":"ready",
|
|
35
|
+
"solution":{
|
|
36
|
+
"confidence":0.9585,
|
|
37
|
+
"text":"gcphjd"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
>>> import asyncio
|
|
42
|
+
>>> from python3_capsolver.image_to_text import ImageToText
|
|
43
|
+
>>> from python3_capsolver.core.captcha_instrument import FileInstrument
|
|
44
|
+
|
|
45
|
+
>>> body = FileInstrument().file_processing(captcha_file="captcha_example.jpeg")
|
|
46
|
+
>>> asyncio.run(ImageToText(api_key="CAI-12345....").aio_captcha_handler(
|
|
47
|
+
... task_payload={"body": body, "module": "common"}
|
|
48
|
+
... )
|
|
49
|
+
... )
|
|
50
|
+
{
|
|
51
|
+
"errorId":0,
|
|
52
|
+
"errorCode":"None",
|
|
53
|
+
"errorDescription":"None",
|
|
54
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
55
|
+
"status":"ready",
|
|
56
|
+
"solution":{
|
|
57
|
+
"confidence":0.9585,
|
|
58
|
+
"text":"gcphjd"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
>>> from python3_capsolver.image_to_text import ImageToText
|
|
63
|
+
>>> from python3_capsolver.core.captcha_instrument import FileInstrument
|
|
64
|
+
|
|
65
|
+
>>> body = FileInstrument().file_processing(captcha_file="captcha_example.jpeg")
|
|
66
|
+
>>> ImageToText(api_key="CAI-12345....").captcha_handler(
|
|
67
|
+
... task_payload={"body": body,
|
|
68
|
+
... "module": "common",
|
|
69
|
+
... "score": 0.92}
|
|
70
|
+
... )
|
|
71
|
+
{
|
|
72
|
+
"errorId":0,
|
|
73
|
+
"errorCode":"None",
|
|
74
|
+
"errorDescription":"None",
|
|
75
|
+
"taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
|
|
76
|
+
"status":"ready",
|
|
77
|
+
"solution":{
|
|
78
|
+
"confidence":0.9585,
|
|
79
|
+
"text":"gcphjd"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
99
82
|
|
|
100
83
|
Notes:
|
|
101
84
|
https://docs.capsolver.com/guide/recognition/ImageToTextTask.html
|
|
102
85
|
"""
|
|
103
86
|
|
|
104
|
-
def __init__(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
):
|
|
110
|
-
super().__init__(*args, **kwargs)
|
|
111
|
-
if captcha_type in ImageToTextTaskTypeEnm.list():
|
|
112
|
-
self.task_params = TaskSer(**locals()).dict(exclude_none=True)
|
|
113
|
-
else:
|
|
114
|
-
raise ValueError(
|
|
115
|
-
f"""Invalid `captcha_type` parameter set for `{self.__class__.__name__}`,
|
|
116
|
-
available - {ImageToTextTaskTypeEnm.list()}"""
|
|
117
|
-
)
|
|
118
|
-
for key in kwargs:
|
|
119
|
-
self.task_params.update({key: kwargs[key]})
|
|
120
|
-
|
|
121
|
-
def captcha_handler(self, body: str) -> CaptchaResponseSer:
|
|
87
|
+
def __init__(self, api_key: str, **kwargs):
|
|
88
|
+
|
|
89
|
+
super().__init__(api_key=api_key, captcha_type=CaptchaTypeEnm.ImageToTextTask, **kwargs)
|
|
90
|
+
|
|
91
|
+
def captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
|
|
122
92
|
"""
|
|
123
93
|
Synchronous method for captcha solving
|
|
124
94
|
|
|
125
95
|
Args:
|
|
126
|
-
|
|
96
|
+
task_payload: Captcha solving `task` payload, include `body`, `module` and other fields.
|
|
127
97
|
|
|
128
98
|
Returns:
|
|
129
|
-
|
|
99
|
+
Dict with full server response
|
|
130
100
|
|
|
131
101
|
Notes:
|
|
132
102
|
Check class docstring for more info
|
|
133
103
|
"""
|
|
134
|
-
|
|
135
|
-
return
|
|
104
|
+
task_payload.pop("type", None)
|
|
105
|
+
return super().captcha_handler(task_payload=task_payload)
|
|
136
106
|
|
|
137
|
-
async def aio_captcha_handler(self,
|
|
107
|
+
async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
|
|
138
108
|
"""
|
|
139
109
|
Asynchronous method for captcha solving
|
|
140
110
|
|
|
141
111
|
Args:
|
|
142
|
-
|
|
112
|
+
task_payload: Captcha solving `task` payload, include `body`, `module` and other fields.
|
|
143
113
|
|
|
144
114
|
Returns:
|
|
145
|
-
|
|
115
|
+
Dict with full server response
|
|
146
116
|
|
|
147
117
|
Notes:
|
|
148
118
|
Check class docstring for more info
|
|
149
119
|
"""
|
|
150
|
-
|
|
151
|
-
return await
|
|
120
|
+
task_payload.pop("type", None)
|
|
121
|
+
return await super().aio_captcha_handler(task_payload=task_payload)
|