Skip to content

Instantly share code, notes, and snippets.

@skyl
Created October 3, 2014 18:30

Revisions

  1. skyl created this gist Oct 3, 2014.
    27 changes: 27 additions & 0 deletions unfollow.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    import time
    import sys
    import tweepy

    consumer_key = ""
    consumer_secret = ""
    key = ""
    secret = ""

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(key, secret)

    api = tweepy.API(auth_handler=auth)

    followers_ids = set(api.followers_ids())
    friends_ids = set(api.friends_ids())

    non_friends = friends_ids.difference(followers_ids)

    for i in non_friends:
    u = api.get_user(i)
    print "unfollow", u.name, u.screen_name
    answer = raw_input("Are you sure? [Y/n] ").lower()
    if answer and answer[0] != "y":
    continue
    else:
    u.unfollow()