Skip to content

Commit 59609c7

Browse files
committed
Added methods vkimage, vkcaptcha, prosopo, captchafox to solver.py and async_solver.py, added a description of new captchas to README.md, added tests for new captchas in sync and async, corrected error output in all async examples, corrected the python version and added new captchas to the description in setup.py
Signed-off-by: Maxim S <[email protected]>
1 parent dfed176 commit 59609c7

File tree

81 files changed

+927
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+927
-152
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Examples of API requests for different captcha types are available on the [Pytho
4444
- [DataDome](#datadome)
4545
- [VKImage](#vkimage)
4646
- [VKCaptcha](#vkcaptcha)
47+
- [CaptchaFox](#captchafox)
48+
- [Prosopo](#prosopo)
4749
- [CyberSiARA](#cybersiara)
4850
- [Other methods](#other-methods)
4951
- [send / get\_result](#send--get_result)
@@ -456,7 +458,7 @@ result = solver.vkimage('path/to/captcha.jpg', steps='[5,4,7,7,14,22,8,...]', ..
456458

457459
<sup>[API method description.](https://2captcha.com/2captcha-api#vkcaptcha)</sup>
458460

459-
This method can be used to solve VK Captcha using a token.
461+
This method can be used to solve VK Captcha using a token. Returns a token.
460462

461463
> [!IMPORTANT]
462464
> To solve the VK Captcha, you must use a proxy. It is recommended to use [residential proxies].
@@ -470,6 +472,32 @@ result = solver.vkcaptcha(redirect_uri='https://id.vk.ru/...',
470472
)
471473
```
472474

475+
### CaptchaFox
476+
477+
<sup>[API method description.](https://2captcha.com/2captcha-api#captchafox)</sup>
478+
479+
This method can be used to solve CaptchaFox using a token. Returns a token.
480+
481+
```python
482+
result = solver.captchafox(sitekey='sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH',
483+
pageurl='https://mysite.com/page/with/captchafox',
484+
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
485+
proxy={'type': 'HTTPS',
486+
'uri': 'login:password@IP_address:PORT'})
487+
```
488+
489+
### Prosopo
490+
491+
<sup>[API method description.](https://2captcha.com/2captcha-api#prosopo-procaptcha)</sup>
492+
493+
This method can be used to solve Prosopo captcha using a token. Returns a token.
494+
495+
```python
496+
result = solver.prosopo(sitekey='5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNb1DkVLS0JbqR',
497+
pageurl='https://mysite.com/page/with/prosopo'
498+
)
499+
```
500+
473501
### CyberSiARA
474502

475503
<sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>

examples/async/async_amazon_waf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ async def solve_captcha():
3131
url='https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest',
3232
)
3333
except Exception as e:
34-
print(e)
35-
return e
34+
sys.exit(e)
3635

3736

3837
if __name__ == '__main__':

examples/async/async_amazon_waf_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ async def solve_amazon_waf():
4848
# }
4949
)
5050
except Exception as e:
51-
print(e)
52-
raise e
51+
sys.exit(e)
5352

5453

5554
if __name__ == '__main__':

examples/async/async_atb_captcha.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ async def solve_captcha():
2525
url='http://mysite.com/',
2626
)
2727
except Exception as e:
28-
print(e)
29-
return e
28+
sys.exit(e)
3029

3130

3231
if __name__ == '__main__':

examples/async/async_atb_captcha_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ async def solve_captcha():
3939
# }
4040
)
4141
except Exception as e:
42-
print(e)
43-
return e
42+
sys.exit(e)
4443

4544

4645
if __name__ == '__main__':

examples/async/async_audio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ async def solve_captcha():
2121
try:
2222
return await solver.audio('../audio/example.mp3', lang='en')
2323
except Exception as e:
24-
print(e)
25-
return e
24+
sys.exit(e)
2625

2726

2827
if __name__ == '__main__':

examples/async/async_canvas.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ async def solve_captcha():
2020
try:
2121
return await solver.canvas('../images/canvas.jpg', hintText='Draw around apple')
2222
except Exception as e:
23-
print(e)
24-
return e
23+
sys.exit(e)
2524

2625

2726
if __name__ == '__main__':

examples/async/async_canvas_base64.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ async def solve_captcha():
2626
try:
2727
return await solver.canvas(b64, hintText='Draw around apple')
2828
except Exception as e:
29-
print(e)
30-
return e
29+
sys.exit(e)
3130

3231

3332
if __name__ == '__main__':

examples/async/async_canvas_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ async def solve_captcha():
2828
hintText='Draw around apple',
2929
)
3030
except Exception as e:
31-
print(e)
32-
return e
31+
sys.exit(e)
3332

3433

3534
if __name__ == '__main__':

examples/async/async_captchafox.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import asyncio
2+
import sys
3+
import os
4+
5+
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
6+
7+
from twocaptcha import AsyncTwoCaptcha
8+
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+
15+
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
16+
17+
solver = AsyncTwoCaptcha(api_key)
18+
19+
async def solve_captcha():
20+
try:
21+
return await solver.captchafox(
22+
sitekey='sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH',
23+
pageurl='https://mysite.com/page/with/captchafox',
24+
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
25+
proxy={'type': 'HTTPS',
26+
'uri': 'login:password@IP_address:PORT'}
27+
)
28+
except Exception as e:
29+
sys.exit(e)
30+
31+
if __name__ == '__main__':
32+
result = asyncio.run(solve_captcha())
33+
sys.exit('result: ' + str(result))

0 commit comments

Comments
 (0)