Created
April 17, 2018 14:46
-
-
Save qwert2603/3a38f5ee5b7b1cef476216dca8f985b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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