@@ -273,7 +273,15 @@ def _vk_login(self, captcha_sid=None, captcha_key=None):
273273 'Origin' : 'https://vk.com' ,
274274 }
275275
276- for _ in range (8 ): # idk, maybe less is enough
276+ for _ in range (16 ):
277+ lg_domain_h = search_re (RE_LOGIN_LG_DOMAIN_H , response .text )
278+ if not lg_domain_h :
279+ # a new login form is returned, trying again to get old one
280+ # TODO: support new login form, probably this one 'https://login.vk.com/?act=connect_authorize'
281+ self .http .cookies .clear ()
282+ response = self .http .get ('https://vk.com/' )
283+ time .sleep (0.05 )
284+ continue
277285 values = {
278286 'act' : 'login' ,
279287 'role' : 'al_frame' ,
@@ -285,8 +293,7 @@ def _vk_login(self, captcha_sid=None, captcha_key=None):
285293 '_origin' : 'https://vk.com' ,
286294 'utf8' : '1' ,
287295 'ip_h' : search_re (RE_LOGIN_IP_H , response .text ),
288- 'lg_h' : search_re (RE_LOGIN_LG_H , response .text ),
289- 'lg_domain_h' : search_re (RE_LOGIN_LG_DOMAIN_H , response .text ),
296+ 'lg_domain_h' : lg_domain_h ,
290297 'ul' : '' ,
291298 'email' : self .login ,
292299 'pass' : self .password
@@ -300,7 +307,8 @@ def _vk_login(self, captcha_sid=None, captcha_key=None):
300307 response = self .http .post (
301308 'https://login.vk.com/?act=login' , data = values , headers = headers )
302309 if 'onLoginFailed(7,' in response .text :
303- response = self .http .get ('https://vk.com/login?m=7' )
310+ self .http .cookies .clear ()
311+ response = self .http .get ('https://vk.com/' )
304312 time .sleep (0.2 )
305313 continue
306314 if 'onLoginDone(' in response .text :
0 commit comments