Пример #1
0
import pickle
from tqdm import tqdm
from collections import Counter
from vk_core import Vk

vk = Vk()

wall = vk.get_all('wall.get', {'owner_id': -76552532})
owner_id_counter = Counter()
id_counter = Counter()

for i, wall_item in tqdm(enumerate(wall)):
    post_id = wall_item.get("id", 0)
    owner_id = wall_item.get('owner_id', 0)

    comments_count = wall_item.get("comments", {}).get("count", 0)

    comments = vk.get_all('wall.getComments', {'owner_id': -76552532, 'post_id': post_id, 'count': comments_count})
    comments_user_ids = [str(comment.get('from_id', 0)) for comment in comments if comment.get('from_id', 0)]

    if owner_id:
        owner_id_counter.update(str(owner_id))
        id_counter.update(str(owner_id))
    if comments_user_ids:
        id_counter.update(comments_user_ids)

    # if i % 100 == 0:
    #     with open("vk_dumped.pickle", "wb") as file:
    #         pickle.dump(result, file)

print(owner_id_counter)
Пример #2
0
from vk_core import Vk
from tqdm import tqdm

vk = Vk()
users = vk.get_all('groups.getMembers', {
    'group_id': 58219172
})['items']

users_at_group = []

for user_id in tqdm(users):
    groups = vk.get_all('groups.get', {
        'user_id': user_id
    })
    if groups:
        if 125004421 and 79138567 and 30666517 and 63731512 and 68662114 in groups.get('items'):
            users_at_group.append(user_id)

result = vk.method('users.get', {
    'user_ids': repr(users_at_group)[1:-1],
    'fields': 'domain, first_name, last_name'
})

for user in result:
    print("{} {} – http://new.vk.com/{}".format(user.get('first_name'), user.get('last_name'), user.get('domain')))