Skip to content

Commit 4f17b8e

Browse files
committed
Added Prosopo captcha
1 parent 13fafdd commit 4f17b8e

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed
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)