FileInstrument

To import this module:

from python3_capsolver.core import captcha_instrument
class python3_capsolver.core.captcha_instrument.FileInstrument

This class contains usefull methods for async and async files processing to prepare them for solving

Examples

>>> from python3_capsolver.core.captcha_instrument import FileInstrument
>>> body = FileInstrument().file_processing(captcha_file="captcha_example.jpeg")
/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBUVxxxxx
>>> from python3_capsolver.core.captcha_instrument import FileInstrument
>>> body = FileInstrument().file_processing(captcha_link="https://some-url/file.jpeg")
/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBUVxxxxx
Returns:

String with decoded file data

file_processing(captcha_link: str | None = None, captcha_file: str | None = None, captcha_base64: bytes | None = None, save_format: SaveFormatsEnm = SaveFormatsEnm.TEMP, img_clearing: bool = True, file_path: str = '/tmp/', file_extension: str = 'png', **kwargs) str
Synchronous method for captcha image processing.
  • Method can read local file and return it’s as base64 string.

  • Method can read file URL and return it’s as base64 string.

  • Method can decode base64 bytes and return it’s as base64 string.

Parameters:
  • captcha_link (str | None) – URL link to file. Instrument will send GET request to it and read content

  • captcha_file (str | None) – Local file path. Instrument will read it

  • captcha_base64 (bytes | None) – Readed file base64 data. Instrument will decode it in utf-8

  • save_format (SaveFormatsEnm) – This arg works only with captcha_link arg. If SaveFormatsEnm.CONST is set - file will be loaded and saved locally.

  • img_clearing (bool) – This arg works only with captcha_link arg. If False - file wil not be removed downloading and saving locally.

  • file_path (str) – This arg works only with captcha_link and SaveFormatsEnm.CONST args. In this param u can set locally path for downloaded file saving.

  • file_extension (str) – This arg works only with file_path args. In this param u MUST set file format for saving.

Examples

>>> from python3_capsolver.core.captcha_instrument import FileInstrument
>>> body = FileInstrument().file_processing(captcha_file="captcha_example.jpeg")
/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBUVxxxxx
Returns:

String with decoded file data

Return type:

str

async aio_file_processing(captcha_link: str | None = None, captcha_file: str | None = None, captcha_base64: bytes | None = None, save_format: SaveFormatsEnm = SaveFormatsEnm.TEMP, img_clearing: bool = True, file_path: str = '/tmp/', file_extension: str = 'png', **kwargs) str
Asynchronous method for captcha image processing.
  • Method can read local file and return it’s as base64 string.

  • Method can read file URL and return it’s as base64 string.

  • Method can decode base64 bytes and return it’s as base64 string.

Parameters:
  • captcha_link (str | None) – URL link to file. Instrument will send GET request to it and read content

  • captcha_file (str | None) – Local file path. Instrument will read it

  • captcha_base64 (bytes | None) – Readed file base64 data. Instrument will decode it in utf-8

  • save_format (SaveFormatsEnm) – This arg works only with captcha_link arg. If SaveFormatsEnm.CONST is set - file will be loaded and saved locally.

  • img_clearing (bool) – This arg works only with captcha_link arg. If False - file wil not be removed downloading and saving locally.

  • file_path (str) – This arg works only with captcha_link and SaveFormatsEnm.CONST args. In this param u can set locally path for downloaded file saving.

  • file_extension (str) – This arg works only with file_path args. In this param u MUST set file format for saving.

Examples

>>> import asyncio
>>> from python3_capsolver.core.captcha_instrument import FileInstrument
>>> body = asyncio.run(FileInstrument()
...                     .aio_file_processing(captcha_file="captcha_example.jpeg"))
/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBUVxxxxx
Returns:

String with decoded file data

Return type:

str