Skip to content

Instantly share code, notes, and snippets.

@qwert2603
Created April 17, 2018 14:46
Show Gist options
  • Save qwert2603/3a38f5ee5b7b1cef476216dca8f985b7 to your computer and use it in GitHub Desktop.
Save qwert2603/3a38f5ee5b7b1cef476216dca8f985b7 to your computer and use it in GitHub Desktop.
import requests
ids = [1, 2, 3, 4, 5, 6]
frs = {}
for id in ids:
r = requests.get('https://api.vk.com/method/friends.get', {'user_id': id})
frs.update({id: r.json()['response']})
print(r)
m = {}
for u in frs:
for a in frs[u]:
m.update({a: m.get(a, 0) + 1})
res = {}
for n in range(3, 7):
te = {}
for k in m:
if m[k] == n:
te.setdefault(k, m[k])
res.setdefault(n, te)
for i in res:
print(i)
for j in res[i]:
r = requests.get('https://api.vk.com/method/users.get', {'user_ids': j})
v = r.json()['response'][0]
print(j, v['first_name'], v['last_name'], 'vk.com/id{}'.format(j))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment