Created
March 20, 2011 18:22
-
-
Save shazow/878523 to your computer and use it in GitHub Desktop.
Print all the people you're following on Twitter, for convenient grepping.
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
#!/usr/bin/env python | |
# Print all the people you're following on Twitter. | |
import webbrowser | |
import tweepy | |
import sys | |
def main(): | |
# Twolever app | |
consumer_key, consumer_secret = 'd8BVP2w58kwnVxVT3BrrPQ', 'Wuelj9vieJgzpnfqGTxptYBqN9BT3SYHxQnRzeyBbxg' | |
token_key, token_secret = None, None | |
if len(sys.argv) == 3: | |
token_key, token_secret = sys.argv[1:] | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
if not all([token_key, token_secret]): | |
# No token specified, fetch one from Twitter using OAuth | |
webbrowser.open(auth.get_authorization_url()) | |
pin = raw_input('Verification pin number from twitter.com: ').strip() | |
token = auth.get_access_token(verifier=pin) | |
token_key, token_secret = token.key, token.secret | |
sys.stderr.write("Next time you can run:\n\t%s %s %s\n\n" % (sys.argv[0], token_key, token_secret)) | |
auth.set_access_token(token_key, token_secret) | |
api = tweepy.API(auth) | |
# Print friends | |
for u in tweepy.Cursor(api.friends).items(): | |
print u.screen_name.encode('utf8'), '\t', u.name.encode('utf8') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment