A
A
apiwi2020-09-15 17:59:59
Python
apiwi, 2020-09-15 17:59:59

How to get data using wall.get?

I can not get data from the group wall, I wrote this code:

import vk_api
import datetime
import time
while True: # Не понятно работает или нет. Ошибок не наблюдается.
    vk = vk_api.VkApi(token="токен")
    group_id = '-id' # Сообщество из которого нужно "парсить" так сказать.
    vk.method("wall.get", {"owner_id": group_id, "count":1}) 
    time.sleep(1000)

There are no errors, I can’t understand how I can now “parse” a post from a group, and then use wall.post to send it to the wall of my community.
while True:  #Данный кусок работает, ошибок нет.
        vk = vk_api.VkApi(token="токен")
        group_id = '-id' 
        text = "Тут типо текст для записи"
        vk.method("wall.post", {"owner_id": group_id, "from_group":1, "message": text})
        time.sleep(6000)

How to combine these things?
The essence of the bot: it takes a post from another VK community, and creates the same post, only in my group.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Guerro69, 2020-09-15
@apiwi

Well duck probably need to assign the text to a variable and get to it?

import vk_api
import datetime
import time

vk = vk_api.VkApi(token="токен")
api = vk.get_api()
group_id = -0
my_id = 0

while True:
    text = api.wall.get(owner_id=group_id, count=1)['items'][0]['text']
    api.wall.post(owner_id=my_id, from_group=1, message=text)
    time.sleep(1000)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question