ImageToCoordinates

To import this module:

from python3_anticaptcha.image_to_coordinates import ImageToCoordinates
class python3_anticaptcha.image_to_coordinates.ImageToCoordinates(api_key: str, comment: str | None = None, mode: str = 'points', websiteURL: str | None = None, captcha_type: CaptchaTypeEnm | str = CaptchaTypeEnm.ImageToCoordinatesTask, sleep_time: int = 5, save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, img_clearing: bool = True, img_path: str = 'PythonAntiCaptchaImages')
__init__(api_key: str, comment: str | None = None, mode: str = 'points', websiteURL: str | None = None, captcha_type: CaptchaTypeEnm | str = CaptchaTypeEnm.ImageToCoordinatesTask, sleep_time: int = 5, save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, img_clearing: bool = True, img_path: str = 'PythonAntiCaptchaImages')

The class is used to work with ImageToTextTask.

Parameters:
  • api_key (str) – Capsolver API key

  • comment (str | None) – Comments for the task in English characters only. Example: “Select objects in specified order” or “select all cars”.

  • mode (str) – Task mode, can be “points” or “rectangles”. The default is “points”.

  • websiteURL (str | None) – Optional parameter to distinguish source of image captchas in spending statistics.

  • captcha_type (CaptchaTypeEnm | str) – Captcha type

  • sleep_time (int) – The waiting time between requests to get the result of the Captcha

  • save_format (str | SaveFormatsEnm) – Image save format - temporary or persistance

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

  • img_path (str) – Folder to save captcha images

Examples

>>> ImageToCoordinates(api_key="99d7d111a0111dc11184111c8bb111da",
...                     save_format=SaveFormatsEnm.CONST,
...                     comment="select all cars",
...                     mode="rectangles",
...                     websiteURL="https://some-website.xyz/"
...        ).captcha_handler(captcha_file='files/captcha-image.jpg')
{
   "errorId": 0,
   "errorCode": None,
   "errorDescription": None,
   "status":"ready",
   "solution":{
        "coordinates":[
            [17,48,54,83],
            [76,93,140,164]
        ]
   },
   "cost": 0.002,
   "ip": "46.53.249.230",
   "createTime": 1679004358,
   "endTime": 1679004368,
   "solveCount": 0,
   "taskId": 396687629
}
>>> ImageToCoordinates(api_key="99d7d111a0111dc11184111c8bb111da",
...                     save_format=SaveFormatsEnm.CONST,
...                     comment="select 3 cats",
...                     mode="points",
...                     websiteURL="https://some-website.xyz/"
...        ).captcha_handler(captcha_link='https://........../captcha-image.jpg')
{
   "errorId": 0,
   "errorCode": None,
   "errorDescription": None,
   "status":"ready",
   "solution":{
        "coordinates":[
            [17,48,54,83],
            [76,93,140,164]
        ]
   },
   "cost": 0.002,
   "ip": "46.53.249.230",
   "createTime": 1679004358,
   "endTime": 1679004368,
   "solveCount": 0,
   "taskId": 396687629
}
>>> await ImageToCoordinates(api_key="99d7d111a0111dc11184111c8bb111da",
...                     save_format=SaveFormatsEnm.TEMP,
...                     comment="select 3 cats",
...                     mode="points",
...                     websiteURL="https://some-website.xyz/"
...        ).aio_captcha_handler(captcha_link='https://........../captcha-image.jpg')
{
   "errorId": 0,
   "errorCode": None,
   "errorDescription": None,
   "status":"ready",
   "solution":{
        "coordinates":[
            [17,48,54,83],
            [76,93,140,164]
        ]
   },
   "cost": 0.002,
   "ip": "46.53.249.230",
   "createTime": 1679004358,
   "endTime": 1679004368,
   "solveCount": 0,
   "taskId": 396687629
}
captcha_handler(captcha_link: str | None = None, captcha_file: str | None = None, captcha_base64: bytes | None = None, **additional_params) dict

Synchronous method for captcha solving

Parameters:
  • captcha_link (str | None) – link to captcha image file

  • captcha_file (str | None) – path to local captcha image file

  • captcha_base64 (bytes | None) – captcha image encoded in base64 format

  • additional_params – Some additional parameters that will be used in creating the task and will be passed to the payload under task key. Like proxyLogin, proxyPassword and etc. - more info in service docs

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

Asynchronous method for captcha solving

Parameters:
  • captcha_link (str | None) – link to captcha image file

  • captcha_file (str | None) – path to local captcha image file

  • captcha_base64 (bytes | None) – captcha image encoded in base64 format

  • additional_params – Some additional parameters that will be used in creating the task and will be passed to the payload under task key. Like proxyLogin, proxyPassword and etc. - more info in service docs

Returns:

Dict with full server response

Return type:

dict

Notes

Check class docstirng for more info

set_callback_url(callbackUrl: str) None

Method for callbackUrl param set.

Parameters:

callbackUrl (str) –

Optional web address where we can send the results of captcha task processing. Contents are sent by AJAX POST request and are identical

to the contents of getTaskResult method.