Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
I recently made a similar script for myself, the current entry in json
Here is the code, you can do it for yourself
Before starting, create a file in the folder with the script data.json
and fill it like this
{
"conversations": [
]
}
import vk_api
import json
vk_session = vk_api.VkApi(token='ТОКЕН')
vk = vk_session.get_api()
index = 1
while True:
try:
chat_info = vk.messages.getChat(chat_id=index)
data = json.load(open('data.json', encoding='utf-8'))
srt_info = {'title': f'{chat_info["title"]}', 'id': f'{chat_info["id"]}'}
data['conversations'].append(srt_info)
with open('data.json', 'w', encoding='utf-8') as file:
json.dump(data, file, indent=2, ensure_ascii=False)
file.close()
index += 1
except Exception as e:
print(repr(e))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question