Answer the question
In order to leave comments, you need to log in
How to get the latest comment on a group wall via VK Api?
It is required to check the posts on the wall every 10 minutes and receive it when a new comment appears.
All this is required to be done through the VK API in python.
I know about the method wall.getComment
, but I can’t run through all the messages in the loop and look for new comments for output.
Answer the question
In order to leave comments, you need to log in
I publish my version, which turned out as a result of trial and error:
Written in Python 3 using the VK_api module
while True: #запускаем бесконечный цикл
man_id = str(-29534144) #id группы с которой будем брать посты и комментарии
postidlist = vk.wall.get(owner_id=man_id, count=1, offset=0) #получаем последний пост
a = str(postidlist['items'][0]['id']) #получаем id поста в виде цифры и записываем
comm = vk.wall.getComments(owner_id=man_id, post_id=a, count=1, sort='desc', offset=0) #Получаем последний комментарий
com_text = comm['items'][0]['text'] #вытаскиваем из полученного ответа только текст
print(com_text) #выводим комментарий
time.sleep(5) #засыпаем на 5 секунд
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question