Skip to content

Commit 9cc0b06

Browse files
author
2captcha
authored
Merge pull request #14 from 2captcha/updates
Updates
2 parents c9ef5a4 + 5471e59 commit 9cc0b06

36 files changed

+311
-108
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,22 @@ Also there are few options that can be configured:
4343

4444
```python
4545
config = {
46-
'apiKey': 'YOUR_API_KEY',
47-
'softId': 123,
48-
'callback': 'https://your.site/result-receiver',
49-
'defaultTimeout': 120,
50-
'recaptchaTimeout': 600,
51-
'pollingInterval': 10,
52-
}
46+
'server': '2captcha.com',
47+
'apiKey': 'YOUR_API_KEY',
48+
'softId': 123,
49+
'callback': 'https://your.site/result-receiver',
50+
'defaultTimeout': 120,
51+
'recaptchaTimeout': 600,
52+
'pollingInterval': 10,
53+
}
5354
solver = TwoCaptcha(**config)
5455
```
5556

5657
### TwoCaptcha instance options
5758

5859
|Option|Default value|Description|
5960
|---|---|---|
61+
|server|`2captcha.com`|API server. You can set it to `rucaptcha.com` if your account is registered there|
6062
|softId|-|your software ID obtained after publishing in [2captcha sofware catalog]|
6163
|callback|-|URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings] of your account|
6264
|defaultTimeout|120|Polling timeout in seconds for all captcha types except ReCaptcha. Defines how long the module tries to get the answer from `res.php` API endpoint|
@@ -182,7 +184,7 @@ result = solver.coordinates('path/to/captcha.jpg', param1=..., ...)
182184
### Rotate
183185
This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle.
184186
```python
185-
result = solver.rotate(['path/to/captcha1.jpg', 'path/to/captcha2.jpg', ...], param1=..., ...)
187+
result = solver.rotate('path/to/captcha.jpg', param1=..., ...)
186188
```
187189

188190
## Other methods

examples/canvas.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
44
from twocaptcha import TwoCaptcha
55

6+
# in this example we store the API key inside environment variables that can be set like:
7+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
8+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
9+
# you can just set the API key directly to it's value like:
10+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
11+
612
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
713

814
solver = TwoCaptcha(api_key)
@@ -14,4 +20,4 @@
1420
sys.exit(e)
1521

1622
else:
17-
sys.exit('solved: ' + str(result))
23+
sys.exit('result: ' + str(result))

examples/canvas_base64.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key)
@@ -19,4 +25,4 @@
1925
sys.exit(e)
2026

2127
else:
22-
sys.exit('solved: ' + str(result))
28+
sys.exit('result: ' + str(result))

examples/canvas_options.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55
from twocaptcha import TwoCaptcha
66

7+
# in this example we store the API key inside environment variables that can be set like:
8+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
9+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
10+
# you can just set the API key directly to it's value like:
11+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
12+
713
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
814

9-
solver = TwoCaptcha(api_key, defaultTimeout=120, pollingInterval=5)
15+
solver = TwoCaptcha(api_key, defaultTimeout=120, pollingInterval=5, server='2captcha.com')
1016

1117
try:
1218
result = solver.canvas(
@@ -16,11 +22,10 @@
1622
lang='en',
1723
hintImg='./images/canvas_hint.jpg',
1824
hintText='Draw around apple',
19-
# callback='http://127.0.0.1/test/'
2025
)
2126

22-
except Exception as e:
27+
except Exception as e:
2328
sys.exit(e)
2429

2530
else:
26-
sys.exit('sent: ' + str(result))
31+
sys.exit('result: ' + str(result))

examples/capy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from twocaptcha import TwoCaptcha
66

7+
# in this example we store the API key inside environment variables that can be set like:
8+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
9+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
10+
# you can just set the API key directly to it's value like:
11+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
12+
713
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
814

915
solver = TwoCaptcha(api_key)
@@ -19,4 +25,4 @@
1925
sys.exit(e)
2026

2127
else:
22-
sys.exit('solved: ' + str(result))
28+
sys.exit('result: ' + str(result))

examples/capy_options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from twocaptcha import TwoCaptcha
66

7+
# in this example we store the API key inside environment variables that can be set like:
8+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
9+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
10+
# you can just set the API key directly to it's value like:
11+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
12+
713
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
814

915
solver = TwoCaptcha(api_key, defaultTimeout=30, pollingInterval=5)
@@ -18,4 +24,4 @@
1824
sys.exit(e)
1925

2026
else:
21-
sys.exit('solved: ' + str(result))
27+
sys.exit('result: ' + str(result))

examples/coordinates.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from twocaptcha import TwoCaptcha
66

7+
# in this example we store the API key inside environment variables that can be set like:
8+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
9+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
10+
# you can just set the API key directly to it's value like:
11+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
12+
713
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
814

915
solver = TwoCaptcha(api_key)
@@ -15,4 +21,4 @@
1521
sys.exit(e)
1622

1723
else:
18-
sys.exit('solved: ' + str(result))
24+
sys.exit('result: ' + str(result))

examples/coordinates_base64.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
from twocaptcha import TwoCaptcha
88

9+
# in this example we store the API key inside environment variables that can be set like:
10+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
11+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
12+
# you can just set the API key directly to it's value like:
13+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
14+
915
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
1016

1117
solver = TwoCaptcha(api_key)
@@ -20,4 +26,4 @@
2026
sys.exit(e)
2127

2228
else:
23-
sys.exit('solved: ' + str(result))
29+
sys.exit('result: ' + str(result))

examples/coordinates_options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key, defaultTimeout=120, pollingInterval=5)
@@ -18,4 +24,4 @@
1824
sys.exit(e)
1925

2026
else:
21-
sys.exit('solved: ' + str(result))
27+
sys.exit('result: ' + str(result))

examples/funcaptcha.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from twocaptcha import TwoCaptcha
66

7+
# in this example we store the API key inside environment variables that can be set like:
8+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
9+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
10+
# you can just set the API key directly to it's value like:
11+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
12+
713
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
814

915
solver = TwoCaptcha(api_key)
@@ -17,4 +23,4 @@
1723
sys.exit(e)
1824

1925
else:
20-
sys.exit('solved: ' + str(result))
26+
sys.exit('result: ' + str(result))

examples/funcaptcha_options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from twocaptcha import TwoCaptcha
66

7+
# in this example we store the API key inside environment variables that can be set like:
8+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
9+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
10+
# you can just set the API key directly to it's value like:
11+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
12+
713
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
814

915
solver = TwoCaptcha(api_key, defaultTimeout=180, pollingInterval=15)
@@ -25,4 +31,4 @@
2531
sys.exit(e)
2632

2733
else:
28-
sys.exit('solved: ' + str(result))
34+
sys.exit('result: ' + str(result))

examples/geetest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key)
@@ -22,4 +28,4 @@
2228
sys.exit(e)
2329

2430
else:
25-
sys.exit('solved: ' + str(result))
31+
sys.exit('result: ' + str(result))

examples/geetest_options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key, defaultTimeout=300, pollingInterval=10)
@@ -28,4 +34,4 @@
2834
sys.exit(e)
2935

3036
else:
31-
sys.exit('solved: ' + str(result))
37+
sys.exit('result: ' + str(result))

examples/grid.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key)
@@ -19,4 +25,4 @@
1925
sys.exit(e)
2026

2127
else:
22-
sys.exit('solved: ' + str(result))
28+
sys.exit('result: ' + str(result))

examples/grid_base64.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
from twocaptcha import TwoCaptcha
88

9+
# in this example we store the API key inside environment variables that can be set like:
10+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
11+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
12+
# you can just set the API key directly to it's value like:
13+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
14+
915
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
1016

1117
solver = TwoCaptcha(api_key)
@@ -23,4 +29,4 @@
2329
sys.exit(e)
2430

2531
else:
26-
sys.exit('solved: ' + str(result))
32+
sys.exit('result: ' + str(result))

examples/grid_options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key, defaultTimeout=100, pollingInterval=12)
@@ -25,4 +31,4 @@
2531
sys.exit(e)
2632

2733
else:
28-
sys.exit('solved: ' + str(result))
34+
sys.exit('result: ' + str(result))

examples/hcaptcha.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55

66
from twocaptcha import TwoCaptcha
77

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+
814
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
915

1016
solver = TwoCaptcha(api_key)
1117

1218
try:
1319
result = solver.hcaptcha(
14-
sitekey='10000000-ffff-ffff-ffff-000000000001',
15-
url='https://www.site.com/page/',
20+
sitekey='3ceb8624-1970-4e6b-91d5-70317b70b651',
21+
url='https://2captcha.com/demo/hcaptcha?difficulty=easy',
1622
)
1723

1824
except Exception as e:
1925
sys.exit(e)
2026

2127
else:
22-
sys.exit('solved: ' + str(result))
28+
sys.exit('result: ' + str(result))

0 commit comments

Comments
 (0)