Skip to content

Commit 109997e

Browse files
authored
- Added method atb_captcha to solver.py (2captcha#75)
- Added examples atb_captcha.py, atb_captcha_options.py to examples folder - Added test test_atb_captcha.py to tests folder - Added description of the method to README.md - And fixed example keycaptcha.py removed extra characters "!" in code Signed-off-by: Maxim S <poplers24@gmail.com>
1 parent 21d2a43 commit 109997e

File tree

6 files changed

+136
-1
lines changed

6 files changed

+136
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ result = solver.keycaptcha(s_s_c_user_id=10,
226226

227227
```
228228

229+
230+
### atbCAPTCHA
231+
Use this method to solve atbCaptcha challenge. Returns a token to bypass captcha.
232+
```python
233+
result = solver.atb_captcha(app_id='af25e409b33d722a95e56a230ff8771c',
234+
api_server='https://cap.aisecurius.com',
235+
url='http://mysite.com/',
236+
param1=..., ...)
237+
238+
```
239+
240+
229241
### Capy
230242
Token-based method to bypass Capy puzzle captcha.
231243
```python

examples/atb_captcha.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
5+
6+
from twocaptcha import TwoCaptcha
7+
8+
# in this example we store the API key inside environment variables that can be set like:
9+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
10+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
11+
# you can just set the API key directly to it's value like:
12+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
13+
14+
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
15+
16+
solver = TwoCaptcha(api_key)
17+
18+
try:
19+
result = solver.atb_captcha(
20+
app_id='af25e409b33d722a95e56a230ff8771c',
21+
api_server='https://cap.aisecurius.com',
22+
url='http://mysite.com/',
23+
)
24+
25+
except Exception as e:
26+
sys.exit(e)
27+
28+
else:
29+
sys.exit('result: ' + str(result))

examples/atb_captcha_options.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
5+
6+
from twocaptcha import TwoCaptcha
7+
8+
# in this example we store the API key inside environment variables that can be set like:
9+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
10+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
11+
# you can just set the API key directly to it's value like:
12+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
13+
14+
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
15+
16+
17+
config = {
18+
'server': '2captcha.com', # can be also set to 'rucaptcha.com'
19+
'apiKey': api_key,
20+
'softId': 123,
21+
# 'callback': 'https://your.site/result-receiver', # if set, sovler with just return captchaId, not polling API for the answer
22+
'defaultTimeout': 120,
23+
'recaptchaTimeout': 600,
24+
'pollingInterval': 10,
25+
}
26+
27+
solver = TwoCaptcha(**config)
28+
29+
try:
30+
result = solver.atb_captcha(app_id='af25e409b33d722a95e56a230ff8771c',
31+
api_server='https://cap.aisecurius.com',
32+
url='http://mysite.com/',
33+
# proxy={
34+
# 'type': 'HTTPS',
35+
# 'uri': 'login:password@IP_address:PORT'
36+
# }
37+
)
38+
39+
except Exception as e:
40+
sys.exit(e)
41+
42+
else:
43+
sys.exit('result: ' + str(result))

examples/keycaptcha.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
1515

1616
solver = TwoCaptcha(api_key)
17-
!!!!
17+
1818
try:
1919
result = solver.keycaptcha(
2020
s_s_c_user_id=15,

tests/test_atb_captcha.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
3+
import unittest
4+
5+
try:
6+
from .abstract import AbstractTest
7+
except ImportError:
8+
from abstract import AbstractTest
9+
10+
11+
class AtbCaptchaTest(AbstractTest):
12+
13+
def test_all_params(self):
14+
params = {
15+
'app_id': 'af25e409b33d722a95e56a230ff8771c',
16+
'api_server': 'https://cap.aisecurius.com',
17+
'url': 'http://mysite.com/'
18+
}
19+
20+
sends = {
21+
'method': 'atb_captcha',
22+
'app_id': 'af25e409b33d722a95e56a230ff8771c',
23+
'api_server': 'https://cap.aisecurius.com',
24+
'pageurl': 'http://mysite.com/'
25+
}
26+
27+
return self.send_return(sends, self.solver.atb_captcha, **params)
28+
29+
30+
if __name__ == '__main__':
31+
unittest.main()

twocaptcha/solver.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,26 @@ def lemin(self, captcha_id, div_id, url, **kwargs):
457457
method='lemin',
458458
**kwargs)
459459
return result
460+
461+
def atb_captcha(self, app_id, api_server, url, **kwargs):
462+
'''
463+
Wrapper for solving atbCAPTCHA
464+
465+
Required:
466+
app_id
467+
api_server
468+
url
469+
470+
Optional params:
471+
472+
473+
'''
474+
result = self.solve(app_id=app_id,
475+
api_server=api_server,
476+
url=url,
477+
method='atb_captcha',
478+
**kwargs)
479+
return result
460480

461481

462482
def turnstile(self, sitekey, url, **kwargs):

0 commit comments

Comments
 (0)