Skip to content

Commit 81652ff

Browse files
author
Mark Miller
committed
v1.1.0
1 parent dc3537f commit 81652ff

31 files changed

+272
-82
lines changed

examples/canvas.py

+7-1
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

+7-1
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

+9-4
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+7-1
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

+9-3
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))

examples/hcaptcha_options.py

+26-8
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,38 @@
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

10-
solver = TwoCaptcha(api_key, defaultTimeout=300, pollingInterval=10)
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)
1128

1229
try:
13-
result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',
14-
url='https://www.site.com/page/',
15-
proxy={
16-
'type': 'HTTPS',
17-
'uri': 'login:password@IP_address:PORT'
18-
})
30+
result = solver.hcaptcha(sitekey='3ceb8624-1970-4e6b-91d5-70317b70b651',
31+
url='https://2captcha.com/demo/hcaptcha?difficulty=easy',
32+
# proxy={
33+
# 'type': 'HTTPS',
34+
# 'uri': 'login:password@IP_address:PORT'
35+
# }
36+
)
1937

2038
except Exception as e:
2139
sys.exit(e)
2240

2341
else:
24-
sys.exit('solved: ' + str(result))
42+
sys.exit('result: ' + str(result))

examples/keycaptcha.py

+7-1
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)
@@ -21,4 +27,4 @@
2127
sys.exit(e)
2228

2329
else:
24-
sys.exit('solved: ' + str(result))
30+
sys.exit('result: ' + str(result))

examples/keycaptcha_options.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
sys.exit(e)
2424

2525
else:
26-
sys.exit('solved: ' + str(result))
26+
sys.exit('result: ' + str(result))
2727

2828

0 commit comments

Comments
 (0)