AndreiDrang/python-rucaptcha

#1
The library is intended for software developers and serves to facilitate the work with the RuCaptcha service API.

There are examples of working with the library .

Python version 3.6+ is used.

How to install? How to install?
pip
pip install python-rucaptcha

Source
git clone https://github.com/AndreiDrang/python-rucaptcha.git
cd python-rucaptcha
python setup.py install


Replacing the structure:
Code:
{
  "errorBody":
    {
      "text": "some text",
      "id": 1
    }
}
Per structure:
Code:
{
  "errorBody": "ERROR_NAME"
}
A short example:
Code:
import  requests
from  python_rucaptcha  import  ImageCaptcha , RuCaptchaControl , CallbackClient
# Enter the key from the RuCaptcha service from your account
RUCAPTCHA_KEY  =  ""
# Link to images for decryption
image_link  =  ""

# to get started, you need to register an IP / URL (done from the same IP that you register):
RuCaptchaControl . RuCaptchaControl ( rucaptcha_key = RUCAPTCHA_KEY ). additional_methods ( action = 'add_pingback' , addr = 'http://85.255.8.26/' )
# check registered addresses
answer  =  RuCaptchaControl . RuCaptchaControl ( rucaptcha_key = RUCAPTCHA_KEY ). additional_methods ( action = 'get_pingback' ,json=1)
print(answer)

# you need to come up with a complex name for the queue (15+ characters will do) to get the results of solving the captcha
queue_name  =  'ba86e77f9007_andrei_drang_7436e744_cute_queue'
# register the queue on the callback server
answer  =  requests . post ( f'http: //85.255.8.26: 8001 / register_key ' , json = { ' key ' : queue_name , ' vhost ' : ' rucaptcha_vhost ' })
print ( answer . text )

# create a task in the RuCaptcha service and specify the `pingback` parameter
task_creation_answer  =  ImageCaptcha . ImageCaptcha ( rucaptcha_key = RUCAPTCHA_KEY ,
                                                      pingback = f'85.255.8.26: 8001 / rucaptcha / image_captcha / { queue_name } ' ,
                                                    ).captcha_handler(captcha_link=image_link)

print ( task_creation_answer )
# Two options for obtaining a solution: cache (the result is stored for 1 hour) and the rabbitmq queue (the result is deleted after the first read)
# we connect to the server and wait for the solution of the captcha from the cache
callback_cache_response  =  CallbackClient . CallbackClient ( task_id = task_creation_answer . Get ( 'id' )). captcha_handler ()
# connect to the server and wait for the Captcha solution from RabbitMQ queue
callback_queue_response  =  CallbackClient . CallbackClient ( task_id =task_creation_answer.get('id'), queue_name=queue_name, call_type='queue').captcha_handler()

print(callback_cache_response)
print(callback_queue_response)
Documentation https://githubmemory.com/repo/AndreiDrang/python-rucaptcha