Skip to content

Commit 838192f

Browse files
authored
Merge pull request #217 from AndreiDrang/main
Release v2.1.4
2 parents f1aa60c + b02fb4b commit 838192f

9 files changed

Lines changed: 327 additions & 3 deletions

File tree

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
recaptcha_v2,
2323
recaptcha_v3,
2424
image_to_text,
25+
prosopo_captcha,
26+
friendly_captcha,
2527
image_to_coordinates,
2628
)
2729
from python3_anticaptcha.__version__ import __version__

docs/modules/friend/example.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FriendlyCaptcha
2+
===============
3+
4+
To import this module:
5+
6+
.. code-block:: python
7+
8+
from python3_anticaptcha.friendly_captcha import FriendlyCaptcha
9+
10+
11+
.. autoclass:: python3_anticaptcha.friendly_captcha.FriendlyCaptcha
12+
:members:

docs/modules/prosopo/example.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Prosopo
2+
=======
3+
4+
To import this module:
5+
6+
.. code-block:: python
7+
8+
from python3_anticaptcha.prosopo_captcha import Prosopo
9+
10+
11+
.. autoclass:: python3_anticaptcha.prosopo_captcha.Prosopo
12+
:members:

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sphinx==8.2.1
1+
sphinx==8.3.0
22
pallets_sphinx_themes==2.3.0
33
myst-parser==4.0.1

requirements.style.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# codestyle
2-
isort==5.*
2+
isort==6.*
33
black==25.*
44
autoflake==2.*
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.1.3"
1+
__version__ = "2.1.4"

src/python3_anticaptcha/core/enum.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class CaptchaTypeEnm(str, MyEnum):
5555
# Turnstile
5656
TurnstileTask = "TurnstileTask"
5757
TurnstileTaskProxyless = "TurnstileTaskProxyless"
58+
# FriendlyCaptcha
59+
FriendlyCaptchaTask = "FriendlyCaptchaTask"
60+
FriendlyCaptchaTaskProxyless = "FriendlyCaptchaTaskProxyless"
61+
# FriendlyCaptcha
62+
ProsopoTask = "ProsopoTask"
63+
ProsopoTaskProxyless = "ProsopoTaskProxyless"
5864
# Custom
5965
AntiGateTask = "AntiGateTask"
6066

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
from typing import Union, Optional
2+
3+
from .core.base import CaptchaParams
4+
from .core.enum import ProxyTypeEnm, CaptchaTypeEnm
5+
6+
__all__ = ("FriendlyCaptcha",)
7+
8+
9+
class FriendlyCaptcha(CaptchaParams):
10+
def __init__(
11+
self,
12+
api_key: str,
13+
websiteURL: str,
14+
websiteKey: str,
15+
captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
16+
proxyType: Optional[Union[ProxyTypeEnm, str]] = None,
17+
proxyAddress: Optional[str] = None,
18+
proxyPort: Optional[int] = None,
19+
proxyLogin: Optional[str] = None,
20+
proxyPassword: Optional[str] = None,
21+
userAgent: Optional[str] = None,
22+
sleep_time: Optional[int] = 10,
23+
):
24+
"""
25+
The class is used to work with FriendlyCaptcha.
26+
27+
Args:
28+
api_key: Capsolver API key
29+
captcha_type: Captcha type
30+
websiteURL: Address of the webpage
31+
websiteKey: Friendly Captcha sitekey
32+
proxyType: Type of the proxy
33+
proxyAddress: Proxy IP address IPv4/IPv6. Not allowed to use:
34+
host names instead of IPs,
35+
transparent proxies (where client IP is visible),
36+
proxies from local networks (192.., 10.., 127...)
37+
proxyPort: Proxy port.
38+
proxyLogin: Proxy login.
39+
proxyPassword: Proxy password.
40+
userAgent: Browser UserAgent.
41+
sleep_time: The waiting time between requests to get the result of the Captcha
42+
43+
Examples:
44+
>>> FriendlyCaptcha(api_key="99d7d111a0111dc11184111c8bb111da",
45+
... captcha_type="FriendlyCaptchaTaskProxyless",
46+
... websiteURL="https://demo.arkoselabs.com",
47+
... websiteKey="FCMDESUD3M34857N"
48+
... ).captcha_handler()
49+
{
50+
"errorId": 0,
51+
"errorCode": None,
52+
"errorDescription": None,
53+
"status":"ready",
54+
"solution":{
55+
"token":"0.Qz0.....f1",
56+
"userAgent":"Mozilla/5.0 (Wind.....",
57+
},
58+
"cost": 0.002,
59+
"ip": "46.53.249.230",
60+
"createTime": 1679004358,
61+
"endTime": 1679004368,
62+
"solveCount": 0,
63+
"taskId": 396687629
64+
}
65+
66+
>>> await FriendlyCaptcha(api_key="99d7d111a0111dc11184111c8bb111da",
67+
... captcha_type="FriendlyCaptchaTaskProxyless",
68+
... websiteURL="https://demo.arkoselabs.com",
69+
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6"
70+
... ).aio_captcha_handler()
71+
{
72+
"errorId": 0,
73+
"errorCode": None,
74+
"errorDescription": None,
75+
"status":"ready",
76+
"solution":{
77+
"token":"0.Qz0.....f1",
78+
"userAgent":"Mozilla/5.0 (Wind.....",
79+
},
80+
"cost": 0.002,
81+
"ip": "46.53.249.230",
82+
"createTime": 1679004358,
83+
"endTime": 1679004368,
84+
"solveCount": 0,
85+
"taskId": 396687629
86+
}
87+
88+
>>> FriendlyCaptcha(api_key="99d7d111a0111dc11184111c8bb111da",
89+
... captcha_type="FriendlyCaptchaTask",
90+
... websiteURL="https://demo.arkoselabs.com",
91+
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6",
92+
... proxyType="http",
93+
... proxyAddress="0.0.0.0",
94+
... proxyPort=9988,
95+
... proxyLogin="proxy_login",
96+
... proxyPassword="proxy_password",
97+
... userAgent="some_real_user_agent",
98+
... ).captcha_handler()
99+
{
100+
"errorId": 0,
101+
"errorCode": None,
102+
"errorDescription": None,
103+
"status":"ready",
104+
"solution":{
105+
"token":"0.Qz0.....f1",
106+
"userAgent":"Mozilla/5.0 (Wind.....",
107+
},
108+
"cost": 0.002,
109+
"ip": "46.53.249.230",
110+
"createTime": 1679004358,
111+
"endTime": 1679004368,
112+
"solveCount": 0,
113+
"taskId": 396687629
114+
}
115+
116+
Notes
117+
https://anti-captcha.com/apidoc/task-types/FriendlyCaptchaTask
118+
119+
https://anti-captcha.com/apidoc/task-types/FriendlyCaptchaTaskProxyless
120+
"""
121+
super().__init__(api_key=api_key, sleep_time=sleep_time)
122+
123+
# validation of the received parameters
124+
if captcha_type == CaptchaTypeEnm.FriendlyCaptchaTask:
125+
self.task_params = dict(
126+
type=captcha_type,
127+
websiteURL=websiteURL,
128+
websiteKey=websiteKey,
129+
proxyType=proxyType,
130+
proxyAddress=proxyAddress,
131+
proxyPort=proxyPort,
132+
proxyLogin=proxyLogin,
133+
proxyPassword=proxyPassword,
134+
userAgent=userAgent,
135+
)
136+
elif captcha_type == CaptchaTypeEnm.FriendlyCaptchaTaskProxyless:
137+
self.task_params = dict(
138+
type=captcha_type,
139+
websiteURL=websiteURL,
140+
websiteKey=websiteKey,
141+
)
142+
else:
143+
raise ValueError(
144+
f"Invalid `captcha_type` parameter set for `{self.__class__.__name__}`, \
145+
available - {CaptchaTypeEnm.FriendlyCaptchaTaskProxyless.value,CaptchaTypeEnm.FriendlyCaptchaTask.value}"
146+
)
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
from typing import Union, Optional
2+
3+
from .core.base import CaptchaParams
4+
from .core.enum import ProxyTypeEnm, CaptchaTypeEnm
5+
6+
__all__ = ("Prosopo",)
7+
8+
9+
class Prosopo(CaptchaParams):
10+
def __init__(
11+
self,
12+
api_key: str,
13+
websiteURL: str,
14+
websiteKey: str,
15+
captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.ProsopoTaskProxyless,
16+
proxyType: Optional[Union[ProxyTypeEnm, str]] = None,
17+
proxyAddress: Optional[str] = None,
18+
proxyPort: Optional[int] = None,
19+
proxyLogin: Optional[str] = None,
20+
proxyPassword: Optional[str] = None,
21+
userAgent: Optional[str] = None,
22+
sleep_time: Optional[int] = 10,
23+
):
24+
"""
25+
The class is used to work with Prosopo captcha.
26+
27+
Args:
28+
api_key: Capsolver API key
29+
captcha_type: Captcha type
30+
websiteURL: Address of the webpage
31+
websiteKey: Prosopo sitekey
32+
proxyType: Type of the proxy
33+
proxyAddress: Proxy IP address IPv4/IPv6. Not allowed to use:
34+
host names instead of IPs,
35+
transparent proxies (where client IP is visible),
36+
proxies from local networks (192.., 10.., 127...)
37+
proxyPort: Proxy port.
38+
proxyLogin: Proxy login.
39+
proxyPassword: Proxy password.
40+
userAgent: Browser UserAgent.
41+
sleep_time: The waiting time between requests to get the result of the Captcha
42+
43+
Examples:
44+
>>> Prosopo(api_key="99d7d111a0111dc11184111c8bb111da",
45+
... captcha_type="ProsopoTaskProxyless",
46+
... websiteURL="https://demo.arkoselabs.com",
47+
... websiteKey="FCMDESUD3M34857N"
48+
... ).captcha_handler()
49+
{
50+
"errorId": 0,
51+
"errorCode": None,
52+
"errorDescription": None,
53+
"status":"ready",
54+
"solution":{
55+
"token":"0.Qz0.....f1",
56+
"userAgent":"Mozilla/5.0 (Wind.....",
57+
},
58+
"cost": 0.002,
59+
"ip": "46.53.249.230",
60+
"createTime": 1679004358,
61+
"endTime": 1679004368,
62+
"solveCount": 0,
63+
"taskId": 396687629
64+
}
65+
66+
>>> await Prosopo(api_key="99d7d111a0111dc11184111c8bb111da",
67+
... captcha_type="ProsopoTaskProxyless",
68+
... websiteURL="https://demo.arkoselabs.com",
69+
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6"
70+
... ).aio_captcha_handler()
71+
{
72+
"errorId": 0,
73+
"errorCode": None,
74+
"errorDescription": None,
75+
"status":"ready",
76+
"solution":{
77+
"token":"0.Qz0.....f1",
78+
"userAgent":"Mozilla/5.0 (Wind.....",
79+
},
80+
"cost": 0.002,
81+
"ip": "46.53.249.230",
82+
"createTime": 1679004358,
83+
"endTime": 1679004368,
84+
"solveCount": 0,
85+
"taskId": 396687629
86+
}
87+
88+
>>> Prosopo(api_key="99d7d111a0111dc11184111c8bb111da",
89+
... captcha_type="ProsopoTask",
90+
... websiteURL="https://demo.arkoselabs.com",
91+
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6",
92+
... proxyType="http",
93+
... proxyAddress="0.0.0.0",
94+
... proxyPort=9988,
95+
... proxyLogin="proxy_login",
96+
... proxyPassword="proxy_password",
97+
... userAgent="some_real_user_agent",
98+
... ).captcha_handler()
99+
{
100+
"errorId": 0,
101+
"errorCode": None,
102+
"errorDescription": None,
103+
"status":"ready",
104+
"solution":{
105+
"token":"0.Qz0.....f1",
106+
"userAgent":"Mozilla/5.0 (Wind.....",
107+
},
108+
"cost": 0.002,
109+
"ip": "46.53.249.230",
110+
"createTime": 1679004358,
111+
"endTime": 1679004368,
112+
"solveCount": 0,
113+
"taskId": 396687629
114+
}
115+
116+
Notes
117+
https://anti-captcha.com/apidoc/task-types/ProsopoTask
118+
119+
https://anti-captcha.com/apidoc/task-types/ProsopoTaskProxyless
120+
"""
121+
super().__init__(api_key=api_key, sleep_time=sleep_time)
122+
123+
# validation of the received parameters
124+
if captcha_type == CaptchaTypeEnm.ProsopoTask:
125+
self.task_params = dict(
126+
type=captcha_type,
127+
websiteURL=websiteURL,
128+
websiteKey=websiteKey,
129+
proxyType=proxyType,
130+
proxyAddress=proxyAddress,
131+
proxyPort=proxyPort,
132+
proxyLogin=proxyLogin,
133+
proxyPassword=proxyPassword,
134+
userAgent=userAgent,
135+
)
136+
elif captcha_type == CaptchaTypeEnm.ProsopoTaskProxyless:
137+
self.task_params = dict(
138+
type=captcha_type,
139+
websiteURL=websiteURL,
140+
websiteKey=websiteKey,
141+
)
142+
else:
143+
raise ValueError(
144+
f"Invalid `captcha_type` parameter set for `{self.__class__.__name__}`, \
145+
available - {CaptchaTypeEnm.ProsopoTaskProxyless.value,CaptchaTypeEnm.ProsopoTask.value}"
146+
)

0 commit comments

Comments
 (0)