Created
October 10, 2011 18:00
Revisions
-
cpu revised this gist
Oct 10, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ try: import twitter except ImportError: print "You must install the python-twitter library." sys.exit(1) -
cpu created this gist
Oct 10, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ ############################################################################### # Quick & Dirty script to download the Avatars of your Twitter Followers # Daniel McCarney -- 10/10/11 # # Emphasis on the quick & dirty. There's no error handling, and bad things # are liable to happen if you have Twitter followers with malicious avatars # # Requirements: Python 2.6, python-twitter, OAuth keys* # # *Twitter requires OAuth authentication for the API calls this script uses. # You'll need to set up an "App" at: https://dev.twitter.com/ and authorize # it access to your account. Take the consumer_key, the consumer_secret, the # access_token_key and the access_token_secret and use them to populate the # settings dictionary. ############################################################################### ############################################################################### ## YOUR OAUTH SETTINGS GO HERE ## ############################################################################### settings = { 'consumer_key' : 'REPLACE_ME_WITH_CONSUMER_KEY', 'consumer_secret' : 'REPLACE_ME_WITH_CONSUMER_SECRET', 'access_token_key' : 'REPLACE_ME_WITH_ACCESS_TOKEN_KEY', 'access_token_secret' : 'REPLACE_ME_WITH_TOKEN_SECRET', } ############################################################################### import sys, os.path, urllib2 try: import twitter except ImportError print "You must install the python-twitter library." sys.exit(1) api = twitter.Api( consumer_key = settings['consumer_key'], consumer_secret = settings['consumer_secret'], access_token_key = settings['access_token_key'], access_token_secret = settings['access_token_secret'] ) followers = api.GetFollowers() imageFetcher = urllib2.build_opener() for user in followers: username = user.GetScreenName() imageURL = user.GetProfileImageUrl() filename = os.path.split(imageURL)[1] extension = os.path.splitext(filename)[1] imageURLConn = imageFetcher.open(imageURL) avatarData = imageURLConn.read() filename = "%s%s" %(username, extension) avatarFile = open(filename, "wb") avatarFile.write(avatarData) avatarFile.close() print "Username: %s File: %s" %(username, filename)