Skip to content

Instantly share code, notes, and snippets.

@skyl skyl/unfollow.py
Created Oct 3, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.