0
# Interactive Captchas
1
2
Methods for solving interactive captcha challenges including reCAPTCHA v2/v3, FunCaptcha, GeeTest, hCaptcha, and other challenge-response systems that require browser interaction.
3
4
## Capabilities
5
6
### reCAPTCHA
7
8
Solves Google reCAPTCHA v2, v3, and Enterprise versions including invisible reCAPTCHA variants.
9
10
```python { .api }
11
def recaptcha(self, sitekey, url, version='v2',
12
enterprise=0, **kwargs):
13
"""
14
Solve reCAPTCHA v2/v3 and Enterprise.
15
16
Parameters:
17
- sitekey (str): Value of sitekey parameter from the page (required)
18
- url (str): Full URL where reCAPTCHA is located (required)
19
- version (str): 'v2' for reCAPTCHA v2, 'v3' for reCAPTCHA v3 (default: 'v2')
20
- enterprise (int): 1 for reCAPTCHA Enterprise, 0 for regular (default: 0)
21
- domain (str): 'google.com' or 'recaptcha.net' (default: 'google.com')
22
- invisible (int): 1 for invisible reCAPTCHA, 0 for visible (default: 0)
23
- action (str): Action parameter for v3 (default: 'verify')
24
- score (float): Minimum score for v3 (default: 0.4, max achievable ~0.3)
25
- data-s (str): Value of data-s parameter for Google Search/services
26
- cookies (str): Cookies in format 'KEY1:Value1;KEY2:Value2'
27
- userAgent (str): User agent string for browser simulation
28
- softId (int): Software developer ID
29
- callback (str): Pingback URL for result notification
30
- proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
31
32
Returns:
33
dict: {'captchaId': str, 'code': str} - code contains the response token
34
"""
35
```
36
37
### FunCaptcha
38
39
Solves FunCaptcha (ArkoseLabs) interactive puzzles and challenges.
40
41
```python { .api }
42
def funcaptcha(self, sitekey, url, **kwargs):
43
"""
44
Solve FunCaptcha/ArkoseLabs challenges.
45
46
Parameters:
47
- sitekey (str): Value of pk or data-pkey parameter (required)
48
- url (str): Full URL where FunCaptcha is located (required)
49
- surl (str): Value of surl parameter if present
50
- userAgent (str): User agent string for browser simulation
51
- data (dict): Custom data parameters in format {'key': 'value'}
52
- softId (int): Software developer ID
53
- callback (str): Pingback URL for result notification
54
- proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
55
56
Returns:
57
dict: {'captchaId': str, 'code': str} - code contains the response token
58
"""
59
```
60
61
### GeeTest
62
63
Solves GeeTest sliding puzzle and behavioral captchas.
64
65
```python { .api }
66
def geetest(self, gt, challenge, url, **kwargs):
67
"""
68
Solve GeeTest captcha challenges.
69
70
Parameters:
71
- gt (str): Value of gt parameter from the page (required)
72
- challenge (str): Value of challenge parameter from the page (required)
73
- url (str): Full URL where GeeTest is located (required)
74
- offline (int): 1 if initGeetest called with offline=true (default: 0)
75
- new_captcha (int): 1 if initGeetest called with new_captcha=true (default: 0)
76
- userAgent (str): User agent string for browser simulation
77
- apiServer (str): Value of api_server parameter if present
78
- softId (int): Software developer ID
79
- callback (str): Pingback URL for result notification
80
- proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
81
82
Returns:
83
dict: {'captchaId': str, 'code': str} - code contains challenge solution
84
"""
85
```
86
87
### GeeTest v4
88
89
Solves the newer GeeTest v4 captcha system with enhanced behavioral analysis.
90
91
```python { .api }
92
def geetest_v4(self, captchaId, url, **kwargs):
93
"""
94
Solve GeeTest v4 captcha.
95
96
Parameters:
97
- captchaId (str): GeeTest v4 captcha ID from the page (required)
98
- url (str): Full URL where GeeTest v4 is located (required)
99
- softId (int): Software developer ID
100
- callback (str): Pingback URL for result notification
101
- proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
102
103
Returns:
104
dict: {'captchaId': str, 'code': str} - code contains v4 solution
105
"""
106
```
107
108
### hCaptcha
109
110
Solves hCaptcha challenges including invisible variants.
111
112
```python { .api }
113
def hcaptcha(self, sitekey, url, **kwargs):
114
"""
115
Solve hCaptcha challenges.
116
117
Parameters:
118
- sitekey (str): Value of data-sitekey parameter (required)
119
- url (str): Full URL where hCaptcha is located (required)
120
- invisible (int): 1 for invisible hCaptcha (rare), 0 for visible (default: 0)
121
- data (str): Custom rqdata value for some implementations
122
- domain (str): 'hcaptcha.com' or 'js.hcaptcha.com' (default: 'hcaptcha.com')
123
- softId (int): Software developer ID
124
- callback (str): Pingback URL for result notification
125
- proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
126
127
Returns:
128
dict: {'captchaId': str, 'code': str} - code contains the response token
129
"""
130
```
131
132
## Usage Examples
133
134
### reCAPTCHA v2
135
136
```python
137
from twocaptcha import TwoCaptcha
138
139
solver = TwoCaptcha('your_api_key')
140
141
# Standard reCAPTCHA v2
142
result = solver.recaptcha(
143
sitekey='6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
144
url='https://www.google.com/recaptcha/api2/demo'
145
)
146
print(f"reCAPTCHA token: {result['code']}")
147
148
# Invisible reCAPTCHA with proxy
149
result = solver.recaptcha(
150
sitekey='your_site_key',
151
url='https://example.com/form',
152
invisible=1,
153
proxy={'type': 'HTTPS', 'uri': 'user:pass@proxy.com:8080'}
154
)
155
print(f"Token: {result['code']}")
156
```
157
158
### reCAPTCHA v3
159
160
```python
161
from twocaptcha import TwoCaptcha
162
163
solver = TwoCaptcha('your_api_key')
164
165
# reCAPTCHA v3 with specific action and score
166
result = solver.recaptcha(
167
sitekey='your_v3_site_key',
168
url='https://example.com/form',
169
version='v3',
170
action='homepage',
171
score=0.3
172
)
173
print(f"v3 token: {result['code']}")
174
```
175
176
### reCAPTCHA Enterprise
177
178
```python
179
from twocaptcha import TwoCaptcha
180
181
solver = TwoCaptcha('your_api_key')
182
183
# reCAPTCHA Enterprise with custom user agent
184
result = solver.recaptcha(
185
sitekey='enterprise_site_key',
186
url='https://enterprise-site.com',
187
enterprise=1,
188
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
189
)
190
print(f"Enterprise token: {result['code']}")
191
```
192
193
### FunCaptcha
194
195
```python
196
from twocaptcha import TwoCaptcha
197
198
solver = TwoCaptcha('your_api_key')
199
200
# Basic FunCaptcha
201
result = solver.funcaptcha(
202
sitekey='your_public_key',
203
url='https://example.com/login'
204
)
205
print(f"FunCaptcha token: {result['code']}")
206
207
# FunCaptcha with custom data
208
result = solver.funcaptcha(
209
sitekey='your_public_key',
210
url='https://example.com/register',
211
surl='https://api.funcaptcha.com',
212
data={'blob': 'custom_data_here'}
213
)
214
print(f"Token: {result['code']}")
215
```
216
217
### GeeTest
218
219
```python
220
from twocaptcha import TwoCaptcha
221
222
solver = TwoCaptcha('your_api_key')
223
224
# Standard GeeTest
225
result = solver.geetest(
226
gt='gt_value_from_page',
227
challenge='challenge_value_from_page',
228
url='https://example.com/login'
229
)
230
print(f"GeeTest solution: {result['code']}")
231
232
# GeeTest with offline mode
233
result = solver.geetest(
234
gt='gt_value',
235
challenge='challenge_value',
236
url='https://example.com',
237
offline=1,
238
new_captcha=1
239
)
240
print(f"Offline solution: {result['code']}")
241
```
242
243
### GeeTest v4
244
245
```python
246
from twocaptcha import TwoCaptcha
247
248
solver = TwoCaptcha('your_api_key')
249
250
# GeeTest v4
251
result = solver.geetest_v4(
252
captchaId='geetest_v4_captchaId',
253
url='https://example.com/v4-captcha'
254
)
255
print(f"GeeTest v4 solution: {result['code']}")
256
```
257
258
### hCaptcha
259
260
```python
261
from twocaptcha import TwoCaptcha
262
263
solver = TwoCaptcha('your_api_key')
264
265
# Standard hCaptcha
266
result = solver.hcaptcha(
267
sitekey='hcaptcha_site_key',
268
url='https://example.com/form'
269
)
270
print(f"hCaptcha token: {result['code']}")
271
272
# Invisible hCaptcha with custom data
273
result = solver.hcaptcha(
274
sitekey='invisible_site_key',
275
url='https://example.com',
276
invisible=1,
277
data='custom_rqdata_value'
278
)
279
print(f"Invisible token: {result['code']}")
280
```
281
282
### Error Handling for Interactive Captchas
283
284
```python
285
from twocaptcha import TwoCaptcha, ApiException, TimeoutException
286
287
solver = TwoCaptcha('your_api_key', recaptchaTimeout=900) # 15 minutes
288
289
try:
290
result = solver.recaptcha(
291
sitekey='invalid_sitekey',
292
url='https://example.com'
293
)
294
except ApiException as e:
295
print(f"API error: {e}")
296
except TimeoutException as e:
297
print(f"Timeout error: {e}")
298
except Exception as e:
299
print(f"Other error: {e}")
300
```