Answer the question
In order to leave comments, you need to log in
Why doesn't it wait for long poll server response in python?
Hello, there is such a problem: when using a long poll connection to VK, the code does not wait for the server's response, and starts doing everything again, the code itself:
import requests
import re
import vk
import urllib.request
while True:
url = "https://api.vk.com/method/messages.getLongPollServer?need_pts=1&access_token=xxx"
response = requests.request('GET', url)
response = response.text
response = str(response)
key = response[20:62]
ts = response[99:109]
pts = response[116:122]
print(response)
url = 'https://imv4.vk.com/im6096?act=a_check&key=' + key + '&ts=' + ts + '&pts=' + pts + 'wait=25&mode=8'
response = requests.request('GET', url, timeout=25)
response = response.text
response = str(response)
response = response.replace("b'", '')
print('resp', response)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question