BoundingBoxCaptcha

To import this module:

from python_rucaptcha.bounding_box_captcha import BoundingBoxCaptcha
class python_rucaptcha.bounding_box_captcha.BoundingBoxCaptcha(comment: str = 'Draw Around Bounding Box', save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, img_clearing: bool = True, img_path: str = 'PythonRuCaptchaBoundingBox', *args, **kwargs)
__init__(comment: str = 'Draw Around Bounding Box', save_format: str | SaveFormatsEnm = SaveFormatsEnm.TEMP, img_clearing: bool = True, img_path: str = 'PythonRuCaptchaBoundingBox', *args, **kwargs)

The class is used to work with Bounding Box.

Parameters:
  • rucaptcha_key – User API key

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

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

  • img_path (str) – Folder to save captcha images

  • kwargs – Additional not required params for this captcha type

Examples

>>> BoundingBoxCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
...             ).captcha_handler(captcha_link="https://rucaptcha.com/dist/web/99581b9d446a509a0a01954438a5e36a.jpg")
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
>>> BoundingBoxCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
...             ).captcha_handler(captcha_file="src/examples/088636.png")
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
>>> with open("src/examples/088636.png", "rb") as f:
...     file_data = f.read()
>>> BoundingBoxCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122"
...             ).captcha_handler(captcha_base64=file_data)
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
>>> await BoundingBoxCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
...             ).aio_captcha_handler(captcha_link="https://rucaptcha.com/dist/web/99581b9d446a509a0a01954438a5e36a.jpg")
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
>>> await BoundingBoxCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
...             ).aio_captcha_handler(captcha_file="src/examples/088636.png")
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}

Death Captcha

>>> BoundingBoxCaptcha(rucaptcha_key="some_username:some_password",
...             service_type="deathbycaptcha"
...             ).captcha_handler(captcha_file="src/examples/088636.jpg")
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
>>> await BoundingBoxCaptcha(rucaptcha_key="some_username:some_password",
...             service_type="deathbycaptcha"
...             ).aio_captcha_handler(captcha_link="https://rucaptcha.com/dist/web/99581b9d446a509a0a01954438a5e36a.jpg")
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
>>> with open("src/examples/088636.png", "rb") as f:
...     file_data = f.read()
>>> await BoundingBoxCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122"
...             ).aio_captcha_handler(captcha_base64=file_data)
{
   "errorId":0,
   "status":"ready",
   "solution":{
        "bounding_boxes": [
            {
                "xMin": 310,
                "xMax": 385,
                "yMin": 231,
                "yMax": 308
            }
        ]
   },
   "cost":0.033,
   "ip":"46.53.241.91",
   "createTime":1696730723,
   "endTime":1696730723,
   "solveCount":1,
   "taskId":74708110322
}
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

Sync solving method

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

  • captcha_file (str | None) – Captcha image file path

  • captcha_base64 (bytes | None) – Captcha image 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

Async solving method

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

  • captcha_file (str | None) – Captcha image file path

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

  • kwargs – additional params for aiohttp library

Returns:

Dict with full server response

Return type:

dict

Notes

Check class docstirng for more info