Last active
June 5, 2016 20:53
-
-
Save OlegWock/0e6e0b990205b219bc74604a593ef4c1 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
#-*- coding: UTF-8 -*- | |
import os, vk_api, sys | |
from time import sleep | |
def captchaHandler(captcha): | |
key = input("Enter Captcha {0}: ".format(captcha.get_url())).strip() | |
return captcha.try_again(key) | |
def getUserId(link): | |
id = link | |
if 'vk.com/' in link: | |
id = link.split('/')[-1] | |
if not id.replace('id', '').isdigit(): | |
id = vk.utils.resolveScreenName(screen_name=id)['object_id'] | |
else: | |
id = id.replace('id', '') | |
return int(id) | |
sl = lambda: sleep(0.35) | |
vk_session = vk_api.VkApi(token=os.environ["OLEG_VK_TOKEN"], captcha_handler=captchaHandler) | |
try: | |
vk_session.authorization() | |
except vk_api.AuthorizationError as error_msg: | |
print(error_msg) | |
vk = vk_session.get_api() | |
peoples = list(map(getUserId, sys.argv[1:])) | |
fr = set(vk.friends.get(user_id=peoples[0])['items']) | |
sl() | |
for p in peoples[1:]: | |
fr = fr & set(vk.friends.get(user_id=p)['items']) | |
sl() | |
for mb in fr: | |
print("http://vk.com/id{}".format(mb)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment