Skip to content

Commit 3a5f2a3

Browse files
committed
Add recaptcha detection
1 parent 869afc3 commit 3a5f2a3

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
@@ -8,6 +8,7 @@
88
"""
99

1010
import logging
11+
import random
1112
import re
1213
import threading
1314
import time
@@ -262,6 +263,14 @@ def vk_login(self, captcha_sid=None, captcha_key=None):
262263

263264
return self.error_handlers[CAPTCHA_ERROR_CODE](captcha)
264265

266+
if 'onLoginReCaptcha(' in response.text:
267+
self.logger.info('Captcha code is required (recaptcha)')
268+
269+
captcha_sid = str(random.random())[2:16]
270+
captcha = Captcha(self, captcha_sid, self.vk_login)
271+
272+
return self.error_handlers[CAPTCHA_ERROR_CODE](captcha)
273+
265274
if 'onLoginFailed(4' in response.text:
266275
raise BadPassword('Bad password')
267276

0 commit comments

Comments
 (0)