Skip to content

Instantly share code, notes, and snippets.

@christophlsa
Created January 14, 2014 16:29
Show Gist options
  • Save christophlsa/8421148 to your computer and use it in GitHub Desktop.
Save christophlsa/8421148 to your computer and use it in GitHub Desktop.
from twitter import *
import json
"""
{
"CONSUMER_KEY": "",
"CONSUMER_SECRET": "",
"OAUTH_TOKEN": "",
"OAUTH_SECRET": ""
}
"""
with open('oauth.json') as data_file:
oauthconf = json.load(data_file)
t = Twitter(auth=OAuth(oauthconf['OAUTH_TOKEN'], oauthconf['OAUTH_SECRET'], oauthconf['CONSUMER_KEY'], oauthconf['CONSUMER_SECRET']))
def chunks(l, n):
return [l[i:i+n] for i in range(0, len(l), n)]
def compare(user1, user2):
results1 = t.followers.ids(screen_name=user1)
results2 = t.followers.ids(screen_name=user2)
user_ids = set(results1['ids']).intersection(results2['ids'])
count = 0
for chunk in chunks(list(user_ids), 100):
users = t.users.lookup(user_id=','.join(str(x) for x in chunk))
for user in users:
print('@{} - {} (folgt: {}, followers: {}, protected: {})'.format(user['screen_name'], user['name'], user['friends_count'], user['followers_count'], user['protected']))
count += 1
print('gesamt: ' + str(count))
if __name__ == "__main__":
compare('accountname1', 'accountname1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment