Skip to content

Instantly share code, notes, and snippets.

@rhema
Created August 11, 2013 05:57

Revisions

  1. rhema created this gist Aug 11, 2013.
    30 changes: 30 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    from twython import Twython, TwythonError
    import time

    APP_KEY = ""#aka Consumer key
    APP_SECRET = ""#aka Consumer secret
    OAUTH_TOKEN = "16279554-"# aka Access token
    OAUTH_TOKEN_SECRET = ""# aka Access token secret

    user_timeline = None

    twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

    twitters = open("whitelist.txt").readlines()

    outfile = open("following.txt","a")

    for tw in twitters:
    try:
    print tw
    tw = tw.strip()
    following = twitter.get_friends_ids(screen_name=tw)
    print following
    following_strs = []
    for f in following['ids']:
    following_strs+=[str(f)]
    outfile.write(",".join([tw]+following_strs)+"\n")
    outfile.flush()
    time.sleep(60)
    except TwythonError as e:
    print e