Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions vk_api/vk_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import threading
import time
import urllib.parse
from hashlib import md5

import requests

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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()

Expand Down