Answer the question
In order to leave comments, you need to log in
How to add schema to string in json format in python?
Good morning, gentlemen. I am writing a small bot for VK. I had to switch from the vk_api library to vk, in the latter the getLongPollServer functions similar in functionality are implemented in a rather interesting way.
In one case (for groups) this function returns the object { server: [ https://blablabla.com] } with the protocol prefix, and in the second case (for messages) it returns only the domain. This is where the difficulty arises later in the code, where you need to call the line
longPoll = post('%s'%server, data = {'act': 'a_check',
'key': key,
'ts': ts,
'wait': 25}).json()
Answer the question
In order to leave comments, you need to log in
I don't even know why, but now the
server = 'http://' + server method, as well as
longPoll = post('http://' + '%s'%server '
both started working, although yesterday there was an error, joking Besides...
Parse the server string into components using urlparse , replace scheme with the one you need (http/https) and assemble it back into a string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question