Skip to content

Instantly share code, notes, and snippets.

@fin
Created October 18, 2011 11:09
Show Gist options
  • Save fin/1295179 to your computer and use it in GitHub Desktop.
Save fin/1295179 to your computer and use it in GitHub Desktop.
should i retweet this?
import requests # pip install requests
import json
USER_1 = 'U1'
USER_2 = 'U2'
def get_user_followers(u):
x = json.loads(requests.get('http://api.twitter.com/1/followers/ids.json', params={'screen_name': u}).content)
return set(x)
if __name__ == '__main__':
u1_f = get_user_followers(USER_1)
u2_f = get_user_followers(USER_2)
u1only = u1_f-u2_f
u2only = u2_f-u1_f
print "%(u1)s and %(u2)s have %(c)d followers in common" % {'u1': USER_1, 'u2': USER_2, 'c': len(u1_f.intersection(u2_f))}
print "%(u1)s has %(c)d followers that %(u2)s doesn't have" % {'u1': USER_1, 'u2': USER_2, 'c': len(u1only)}
print "%(u1)s has %(c)d followers that %(u2)s doesn't have" % {'u2': USER_1, 'u1': USER_2, 'c': len(u2only)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment