Last active
December 18, 2015 04:39
-
-
Save coto/5727214 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
""" | |
Use with: | |
python twitter_friends.py > twitter_friends.csv | |
JSON Tools: | |
http://www.jsoneditoronline.org/ | |
http://jsonparser.com/ | |
""" | |
import urllib2 | |
import json | |
screen_name = "your_twitter_name" | |
friends_ids = json.loads(urllib2.urlopen("https://api.twitter.com/1/friends/ids.json?cursor=-1&screen_name="+screen_name).read()) | |
friends_strids = ','.join(str(x) for x in friends_ids["ids"]) | |
friends_json = json.loads(urllib2.urlopen("http://api.twitter.com/1/users/lookup.json?user_id="+friends_strids).read()) | |
for x in friends_json: | |
print "{},{},\"{}\"".format(x["id_str"], x["screen_name"].encode('utf8'), x["name"].encode('utf8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment