VKCaptcha¶
To import this module:
from python_rucaptcha.vk_captcha import VKCaptcha
- class python_rucaptcha.vk_captcha.VKCaptcha(method: str | VKCaptchaEnm = VKCaptchaEnm.VKCaptchaTask, redirectUri: str | None = None, userAgent: str | None = None, proxyType: str | None = None, proxyAddress: str | None = None, proxyPort: int | None = None, proxyLogin: str | None = None, proxyPassword: str | None = None, save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, img_path: str = 'PythonRuCaptchaImages', *args, **kwargs)¶
- __init__(method: str | VKCaptchaEnm = VKCaptchaEnm.VKCaptchaTask, redirectUri: str | None = None, userAgent: str | None = None, proxyType: str | None = None, proxyAddress: str | None = None, proxyPort: int | None = None, proxyLogin: str | None = None, proxyPassword: str | None = None, save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, img_path: str = 'PythonRuCaptchaImages', *args, **kwargs)¶
The class is used to work with VKCaptchaTask and VKCaptchaImageTask.
VKCaptchaTask requires proxy and returns a token. VKCaptchaImageTask takes a captcha image and steps, returns image solution.
- Parameters:
rucaptcha_key – User API key
method (str | VKCaptchaEnm) – Captcha type - VKCaptchaTask or VKCaptchaImageTask
redirectUri (str | None) – The URL that is returned on requests to the captcha API (VKCaptchaTask)
userAgent (str | None) – User-Agent of your browser will be used to load the captcha (VKCaptchaTask)
proxyType (str | None) – Proxy type - http, https, socks5 (VKCaptchaTask)
proxyAddress (str | None) – Proxy IP address or hostname (VKCaptchaTask)
proxyPort (int | None) – Proxy port (VKCaptchaTask)
proxyLogin (str | None) – Proxy login (VKCaptchaTask)
proxyPassword (str | None) – Proxy password (VKCaptchaTask)
save_format (str | SaveFormatsEnm) – Image save format for VKCaptchaImageTask - ‘temp’ or ‘const’
img_path (str) – Folder to save captcha images for VKCaptchaImageTask
kwargs – Not required params for task creation request
Examples
>>> VKCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122", ... redirectUri="https://id.vk.com/not_robot_captcha?domain=vk.com...", ... userAgent="Mozilla/5.0 .....", ... proxyType="socks5", ... proxyAddress="1.2.3.4", ... proxyPort=445, ... ).captcha_handler() { "errorId":0, "status":"ready", "solution":{ "token":"142000f.....er" }, "cost":"0.002", "ip":"1.2.3.4", "createTime":1692863536, "endTime":1692863556, "solveCount":0, "taskId": 73243152973, }
>>> await VKCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122", ... redirectUri="https://id.vk.com/not_robot_captcha?domain=vk.com...", ... userAgent="Mozilla/5.0 .....", ... proxyType="socks5", ... proxyAddress="1.2.3.4", ... proxyPort=445, ... ).aio_captcha_handler() { "errorId":0, "status":"ready", "solution":{ "token":"142000f.....er" }, "cost":"0.002", "ip":"1.2.3.4", "createTime":1692863536, "endTime":1692863556, "solveCount":0, "taskId": 73243152973, }
>>> VKCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122", ... method=VKCaptchaEnm.VKCaptchaImageTask, ... ).captcha_handler( ... captcha_link="https://example.com/vk_captcha.png", steps=[3, 4, 5] ... ) { "errorId":0, "status":"ready", "solution":{ "best_step": 1, "preview": "...", "solution": "...", "answer": "..." }, "cost":"0.002", "ip":"1.2.3.4", "createTime":1692863536, "endTime":1692863556, "solveCount":0, "taskId": 73243152973, }
- Returns:
Dict with full server response
- captcha_handler(captcha_link: str | None = None, captcha_file: str | None = None, captcha_base64: bytes | None = None, steps: list[int] | None = None, **kwargs: dict[str, Any]) dict[str, Any]¶
Sync solving method
- Parameters:
captcha_link (str | None) – Captcha image URL (VKCaptchaImageTask)
captcha_file (str | None) – Captcha image file path (VKCaptchaImageTask)
captcha_base64 (bytes | None) – Captcha image BASE64 info (VKCaptchaImageTask)
steps (list[int] | None) – List of step values for VKCaptchaImageTask
kwargs (dict[str, Any]) – additional params for requests library
- Returns:
Dict with full server response
- Return type:
dict[str, Any]
Notes
Check class docstirng for more info
- async aio_captcha_handler(captcha_link: str | None = None, captcha_file: str | None = None, captcha_base64: bytes | None = None, steps: list[int] | None = None, **kwargs: dict[str, Any]) dict[str, Any]¶
Async solving method
- Parameters:
captcha_link (str | None) – Captcha image URL (VKCaptchaImageTask)
captcha_file (str | None) – Captcha image file path (VKCaptchaImageTask)
captcha_base64 (bytes | None) – Captcha image BASE64 info (VKCaptchaImageTask)
steps (list[int] | None) – List of step values for VKCaptchaImageTask
kwargs (dict[str, Any]) – additional params for aiohttp library
- Returns:
Dict with full server response
- Return type:
dict[str, Any]
Notes
Check class docstirng for more info