W
W
Wet_Dumplings2019-07-04 22:52:38
Python
Wet_Dumplings, 2019-07-04 22:52:38

How to get the id and repost of a post by a user in VK?

Hey!
Ideally, you need to pull out all over the public, but I will be glad if you tell me how to snatch data from at least one post =))
I get information from the record by

session = vk.AuthSession(app_id=MyVkData.APP_ID, user_login=MyVkData.LOGIN, user_password='hardPassword129rynh')
vkapi = vk.API(session)



comments = vkapi.wall.getComments(owner_id="-50035681",post_id="266057",count='25', v="5.95")

//и прикладываю пандас
import pandas as pd
import json


data = comments
json_str = json.dumps(data)
resp=json.loads(json_str)
print(resp)
df = pd.io.json.json_normalize(data['items'])
print(df)

//df.to_csv(r'comment.csv', index=False)

I get "incomprehensible" story
spoiler
{'count': 5, 'items': [{'id': 266058, 'from_id': 541018061, 'post_id': 266057, 'owner_id': -50035681, 'parents_stack': [], 'date': 1562265428, 'text': 'В Кировске грибов Нет!', 'thread': {'count': 0, 'items': [], 'can_post': True, 'show_reply_button': True, 'groups_can_post': True}}, {'id': 266064, 'from_id': 337561665, 'post_id': 266057, 'owner_id': -50035681, 'parents_stack': [], 'date': 1562266065, 'text': 'Как понимаю на станции.,Имандра набрали)))здорово))))', 'thread': {'count': 1, 'items': [], 'can_post': True, 'show_reply_button': True, 'groups_can_post': True}}, {'id': 266074, 'from_id': 362679868, 'post_id': 266057, 'owner_id': -50035681, 'parents_stack': [], 'date': 1562268036, 'text': 'Улов? Чё ж не удой?) Шутка.', 'thread': {'count': 0, 'items': [], 'can_post': True, 'show_reply_button': True, 'groups_can_post': True}}, {'id': 266082, 'from_id': 150668224, 'post_id': 266057, 'owner_id': -50035681, 'parents_stack': [], 'date': 1562269303, 'text': 'сегодня ходил в районе коашвы часа так 2, ни одного гриба!!!', 'thread': {'count': 0, 'items': [], 'can_post': True, 'show_reply_button': True, 'groups_can_post': True}}], 'current_level_count': 4, 'can_post': True, 'show_reply_button': True, 'groups_can_post': True}
date from_id ... thread.items thread.show_reply_button
0 1562265428 541018061 ... [] True
1 1562266065 337561665 ... [] True
2 1562268036 362679868 ... [] True
3 1562269303 150668224 ... [] True

How can I extract data from this to write down as a result
[user id] == [number of comments] == [whether the post was reposted]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2019-07-05
@Wet_Dumplings

It 's all here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question