diff --git a/vk_api/vk_api.py b/vk_api/vk_api.py index da12fcc..e4344e4 100644 --- a/vk_api/vk_api.py +++ b/vk_api/vk_api.py @@ -13,6 +13,7 @@ import threading import time import urllib.parse +from hashlib import md5 import requests @@ -255,6 +256,11 @@ def _vk_login(self, captcha_sid=None, captcha_key=None): # Get cookies response = self.http.get('https://vk.com/login') + if response.url.startswith('https://vk.com/429.html?'): + hash429_md5 = md5(self.http.cookies['hash429'].encode('ascii')).hexdigest() + self.http.cookies.pop('hash429') + response = self.http.get(f'{response.url}&key={hash429_md5}') + headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', @@ -654,6 +660,7 @@ def method(self, method, values=None, captcha_sid=None, captcha_key=None, response = self.http.post( 'https://api.vk.com/method/' + method, values, + headers={'Cookie': ''} ) self.last_request = time.time()