Skip to content

Instantly share code, notes, and snippets.

@nekofar
Created March 3, 2019 04:55
Show Gist options
  • Save nekofar/4f04d1ea65aac289ee3db2bdb4d55f81 to your computer and use it in GitHub Desktop.
Save nekofar/4f04d1ea65aac289ee3db2bdb4d55f81 to your computer and use it in GitHub Desktop.
Create the list of unfollowers on Twitter using Python
import twitter
# Twitter username
SCREEN_NAME = 'VVVVVVVV'
# Consumer API keys
CONSUMER_KEY = 'WWWWWWWW'
CONSUMER_SECRET = 'XXXXXXXX'
# Access token & access token secret
ACCESS_TOKEN = 'YYYYYYYY'
ACCESS_TOKEN_SECRET = 'ZZZZZZZZ'
# Create an Api instance.
api = twitter.Api(consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
access_token_key=ACCESS_TOKEN,
access_token_secret=ACCESS_TOKEN_SECRET,
sleep_on_rate_limit=True)
# Retrieve the list of followers IDs
followers_ids = api.GetFriendIDs()
# Retrieve the list of following IDs
following_ids = api.GetFollowerIDs()
# Extract the list of followings who don't follow
unfollowers_ids = list(set(followers_ids) - set(following_ids))
# Add users to the list for manual review
api.CreateListsMember(slug='unfollowers',
user_id=unfollowers_ids,
owner_screen_name=SCREEN_NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment