Skip to content

Commit d574c50

Browse files
committed
added vkimage
1 parent ab58fd8 commit d574c50

6 files changed

Lines changed: 76 additions & 6 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Examples of API requests for different captcha types are available on the [Pytho
4242
- [Cutcaptcha](#cutcaptcha)
4343
- [Tencent](#tencent)
4444
- [DataDome](#datadome)
45+
- [VKImage](#vkimage)
4546
- [CyberSiARA](#cybersiara)
4647
- [Other methods](#other-methods)
4748
- [send / get\_result](#send--get_result)
@@ -439,6 +440,16 @@ result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?
439440
},
440441
param1=..., ...)
441442
```
443+
### VKImage
444+
445+
<sup>[API method description.](https://2captcha.com/2captcha-api#vkcaptcha)</sup>
446+
447+
This method can be used to solve VK captcha using graphical captcha. Returns the number of steps and solution value in the target site's API format. Or get an extended response by passing the `extendedResponse=True` attribute to the class instance
448+
449+
```python
450+
result = solver.vkimage('path/to/captcha.jpg', steps='[5,4,7,7,14,22,8,...]', ...)
451+
```
452+
442453

443454
### CyberSiARA
444455

examples/vkimage.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
solver = TwoCaptcha(api_key)
1717

1818
try:
19-
result = solver.geetest_v4(captcha_id='e392e1d7fd421dc63325744d5a2b9c73',
20-
url='https://2captcha.com/demo/geetest-v4')
19+
result = solver.vkimage(files='./images/vk.jpg',
20+
steps='[5,4,7,7,14,22,8,3,2,7,23,22,2,8,24,5,9,20,2,5,0,6,22,4,5,11,12,12,9,6,18,3,21,18,17,'
21+
'7,6,1,4,19,8,11,3,14,20,6,16,11,23,0,10,14,10,9,24,3,14,14,10,0,15,10,6,6,20,12,18,13,'
22+
'20,7,13,9,22,14,24,14,17,22,0,4,6,11,10,15,18,20,0,3,6,4,23,12,15,14,18,4,2,9,5,2]',
23+
)
2124

2225
except Exception as e:
2326
sys.exit(e)

examples/vkimage_base64.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
import os
33
import requests
4+
from base64 import b64encode
45
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
56

67
from twocaptcha import TwoCaptcha
@@ -15,8 +16,11 @@
1516

1617
solver = TwoCaptcha(api_key)
1718

19+
with open('./images/vk.jpg', 'rb') as f:
20+
b64 = b64encode(f.read()).decode('utf-8')
21+
1822
try:
19-
result = solver.vkimage(files='./images/vk.jpg',
23+
result = solver.vkimage(files=b64,
2024
steps='[5,4,7,7,14,22,8,3,2,7,23,22,2,8,24,5,9,20,2,5,0,6,22,4,5,11,12,12,9,6,18,3,21,18,17,'
2125
'7,6,1,4,19,8,11,3,14,20,6,16,11,23,0,10,14,10,9,24,3,14,14,10,0,15,10,6,6,20,12,18,13,'
2226
'20,7,13,9,22,14,24,14,17,22,0,4,6,11,10,15,18,20,0,3,6,4,23,12,15,14,18,4,2,9,5,2]',

examples/vkimage_options.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@
1313

1414
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
1515

16-
solver = TwoCaptcha(api_key)
16+
config = {
17+
'server': '2captcha.com', # can be also set to 'rucaptcha.com'
18+
'apiKey': api_key,
19+
'softId': 123,
20+
'defaultTimeout': 120,
21+
'recaptchaTimeout': 600,
22+
'pollingInterval': 10,
23+
}
24+
25+
solver = TwoCaptcha(**config)
1726

1827
try:
1928
result = solver.vkimage(files='./images/vk.jpg',
20-
steps='[5,4,7,7,14,22,8,3,2,7,23,22,2,8,24,5,9,20,2,5,0,6,22,4,5,11,12,12,9,6,18,3,21,18,17,7,6,1,4,19,8,11,3,14,20,6,16,11,23,0,10,14,10,9,24,3,14,14,10,0,15,10,6,6,20,12,18,13,20,7,13,9,22,14,24,14,17,22,0,4,6,11,10,15,18,20,0,3,6,4,23,12,15,14,18,4,2,9,5,2]',
29+
steps='[5,4,7,7,14,22,8,3,2,7,23,22,2,8,24,5,9,20,2,5,0,6,22,4,5,11,12,12,9,6,18,3,21,18,17,'
30+
'7,6,1,4,19,8,11,3,14,20,6,16,11,23,0,10,14,10,9,24,3,14,14,10,0,15,10,6,6,20,12,18,13,'
31+
'20,7,13,9,22,14,24,14,17,22,0,4,6,11,10,15,18,20,0,3,6,4,23,12,15,14,18,4,2,9,5,2]',
2132
)
2233

2334
except Exception as e:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def get_version():
3636
'2captcha', 'captcha', 'api', 'captcha solver', 'reCAPTCHA',
3737
'FunCaptcha', 'Geetest', 'image captcha', 'Coordinates', 'Click Captcha',
3838
'Geetest V4', 'Lemin captcha', 'Amazon WAF', 'Cloudflare Turnstile',
39-
'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'Cutcaptcha', 'DataDome', 'cybersiara'],
39+
'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'Cutcaptcha', 'DataDome', 'VK Captcha', 'cybersiara'],
4040
python_requires='>=3.6',
4141
test_suite='tests')

twocaptcha/solver.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,47 @@ def cutcaptcha(self, misery_key, apikey, url, **kwargs):
930930
**kwargs)
931931
return result
932932

933+
def vkimage(self, files, steps, **kwargs):
934+
'''Wrapper for solving vkimage captcha.
935+
936+
Parameters
937+
__________
938+
file : str
939+
Captcha image as a file or base64.
940+
steps: str
941+
Array of steps.
942+
proxy : dict, optional
943+
{'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}.
944+
'''
945+
946+
if isinstance(files, str):
947+
948+
payload = self.get_method(files)
949+
payload.pop('method', None)
950+
951+
result = self.solve(method='vkimage', steps=steps, **payload, **kwargs)
952+
return result
953+
954+
elif isinstance(files, dict):
955+
files = list(files.values())
956+
957+
files = self.extract_files(files)
958+
959+
result = self.solve(method='vkimage',
960+
files=files,
961+
steps=steps,
962+
**kwargs)
963+
return result
964+
965+
def vkcaptcha(self, redirect_uri, userAgent, proxytype, proxy):
966+
967+
result = self.solve(misery_key=misery_key,
968+
api_key=apikey,
969+
url=url,
970+
method='cutcaptcha',
971+
**kwargs)
972+
return result
973+
933974
def datadome(self, captcha_url, pageurl, userAgent, proxy, **kwargs):
934975
"""Wrapper for solving DataDome Captcha.
935976

0 commit comments

Comments
 (0)