Skip to content

Instantly share code, notes, and snippets.

@a3r0id
Created July 29, 2022 18:47
Show Gist options
  • Save a3r0id/2e52b14c7327e52bec1cde8403518ac2 to your computer and use it in GitHub Desktop.
Save a3r0id/2e52b14c7327e52bec1cde8403518ac2 to your computer and use it in GitHub Desktop.
import tweepy
from time import sleep
# Unfollows all users that aren't following you back.
# Twitter's rate-limiting allows about 800 unfollows per session.
SCREEN_NAME = "YOUR_TWITTER_HANDLE"
# Twitter Auth
auth = tweepy.OAuthHandler("", "")
auth.set_access_token("", "")
api = tweepy.API(auth)
followers = api.followers_ids(SCREEN_NAME)
friends = api.friends_ids(SCREEN_NAME)
for f in friends:
if f not in followers:
print ("Unfollowed {0}".format(api.get_user(f).screen_name))
api.destroy_friendship(f)
sleep(0.25)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment