M
M
MrJoe2015-08-08 13:48:55
Python
MrJoe, 2015-08-08 13:48:55

How to get captcha information using VK API?

Hello.
The following problem arose: after some requests from my script, VK sometimes asks to enter a captcha. As I understand it, if you use the VK API for Python, then an exception with an error number is also thrown. But inside the exception there is no information about the captcha.
The exception class is described here: https://github.com/dimka665/vk/blob/master/vk/exce...
Actually, the question is how to get the captcha_sid and captcha_img fields .
There is something similar in this question, but here the request is not made using the VK API: A request to the VK API with the captcha_key parameters returns another captcha, what is the error? I would like to understand how to do this using the VK API for Python.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
ar4ebaldello, 2015-08-08
@MrJoe

In the repository, in the exceptions.py file , there is a class "VkAPIMethodError". Its constructor(?) contains the line self.error = error. You can try to catch the error and call exception.error.get('captcha_sid')
I don't use python myself, maybe I'm wrong.

L
lainysss, 2019-02-05
@lainysss

try:
    ....
except vk_api.Captcha as e:
    e.url #картинка с капчей
    e.sid #sid капчи для отправки ответа

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question