Skip to content

Commit

Permalink
Pass 429.html
Browse files Browse the repository at this point in the history
  • Loading branch information
python273 committed Jun 25, 2022
1 parent d5de703 commit 61d7042
Showing 1 changed file with 7 additions and 0 deletions.
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

2 comments on commit 61d7042

@guhbap
Copy link

@guhbap guhbap commented on 61d7042 Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подскажите, зачем тут эта очистка куков? у меня без нее все методы кидыют ошибку запросов в секунду

@python273
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guhbap именно с этой строкой? Апи вроде не должно на куки смотреть

Please sign in to comment.