Skip to content

Commit 71af8c0

Browse files
committed
Merge pull request #23 from AlexTalker/captcha-image
Implement availability Captcha image directly from object
2 parents 99ede5b + fb795aa commit 71af8c0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

vk_api/vk_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def __init__(self, vk, captcha_sid,
574574

575575
self.key = None
576576
self.url = url
577+
self.image = None
577578

578579
def get_url(self):
579580
""" Возвращает ссылку на изображение капчи
@@ -585,6 +586,14 @@ def get_url(self):
585586

586587
return self.url
587588

589+
def get_image(self):
590+
""" Возвращает бинарное изображение капчи, получаемое по get_url()
591+
"""
592+
593+
if not self.image:
594+
self.image = self.vk.http.get(self.get_url()).content
595+
return self.image
596+
588597
def try_again(self, key):
589598
""" Отправляет запрос заново с ответом капчи
590599

0 commit comments

Comments
 (0)