Skip to content

Instantly share code, notes, and snippets.

@skyl
Created October 3, 2014 18:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyl/09439808346fe9cea128 to your computer and use it in GitHub Desktop.
Save skyl/09439808346fe9cea128 to your computer and use it in GitHub Desktop.
Selectively unfollow people who don't follow you on twitter with gruesome and gory confirmation
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment