Created
March 3, 2019 04:55
-
-
Save nekofar/4f04d1ea65aac289ee3db2bdb4d55f81 to your computer and use it in GitHub Desktop.
Create the list of unfollowers on Twitter using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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