AudioCaptcha

To import this module:

from python_rucaptcha.audio_captcha import AudioCaptcha
class python_rucaptcha.audio_captcha.AudioCaptcha(save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, audio_clearing: bool = True, audio_path: str = 'PythonRuCaptchaAudio', lang: str = 'en', *args, **kwargs)
__init__(save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, audio_clearing: bool = True, audio_path: str = 'PythonRuCaptchaAudio', lang: str = 'en', *args, **kwargs)

The class is used to work with Text Captcha.

Parameters:
  • rucaptcha_key – User API key

  • save_format (str | SaveFormatsEnm) – The format in which the file will be saved, or as a temporary file - ‘temp’, or as a regular file to a folder created by the library - ‘const’.

  • audio_clearing (bool) – True - delete file after solution, False - don’t delete file after solution

  • audio_path (str) – Folder to save captcha audio

  • lang (str) – Captcha audio lang: en, fr, de, el, pt, ru

Examples

>>> AudioCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
...             lang='en'
...             ).captcha_handler(captcha_file='examples/mediacaptcha_audio/recaptcha_55914.mp3')
{
    'captchaSolve': 'five five nine one four',
    'taskId': 73243152973,
    'error': False,
    'errorBody': None
}
>>> with open("src/examples/mediacaptcha_audio/recaptcha_55914.mp3", "rb") as f:
...     file_data = f.read()
>>> AudioCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122"
...             ).captcha_handler(captcha_base64=file_data)
{
    'captchaSolve': 'five five nine one four',
    'taskId': 73243152973,
    'error': False,
    'errorBody': None
}
>>> await AudioCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
...             lang='en'
...             ).aio_captcha_handler(captcha_file='examples/mediacaptcha_audio/recaptcha_55914.mp3')
{
    'captchaSolve': 'five five nine one four',
    'taskId': 73243152973,
    'error': False,
    'errorBody': None
}
>>> with open("src/examples/mediacaptcha_audio/recaptcha_55914.mp3", "rb") as f:
...     file_data = f.read()
>>> await AudioCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122"
...             ).aio_captcha_handler(captcha_base64=file_data)
{
    'captchaSolve': 'five five nine one four',
    'taskId': 73243152973,
    'error': False,
    'errorBody': None
}
Returns:

Dict with full server response

captcha_handler(captcha_link: str | None = None, captcha_file: str | None = None, captcha_base64: bytes | None = None, **kwargs) dict

Synchronous method for captcha solving

Parameters:
  • captcha_link (str | None) – Captcha file URL

  • captcha_file (str | None) – Captcha file path

  • captcha_base64 (bytes | None) – Captcha file BASE64 info

  • kwargs – additional params for requests library

Returns:

Dict with full server response

Return type:

dict

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, **kwargs) dict

Asynchronous method for captcha solving

Parameters:
  • captcha_link (str | None) – Captcha file URL

  • captcha_file (str | None) – Captcha file path

  • captcha_base64 (bytes | None) – Captcha file BASE64

  • kwargs – additional params for aiohttp library

Returns:

Dict with full server response

Return type:

dict

Notes

Check class docstirng for more info