Skip to content

Instantly share code, notes, and snippets.

@ozars
Last active August 25, 2018 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozars/e0984d586eae48183f8be886c0edf5af to your computer and use it in GitHub Desktop.
Save ozars/e0984d586eae48183f8be886c0edf5af to your computer and use it in GitHub Desktop.
Simple python script for taking snapshot of Twitter followers

Dump Twitter Followers

I was looking for tracking my unfollowers in Twitter. Yet, online services require bunch of unnecessary permissions, which I don't like to give. So, I wrote this simple script.

This python script dumps number of Twitter followers and ID and screen name of followers at that moment. Useful for simple tracking of unfollowers or new followers. (Dump script output to file now and then, and then inspect diff for unfollowers or new followers)

Usage

  • Install python.
  • Get API keys from Twitter's developer platform if you don't have already. Replace REPLACE_THIS parts in below script with consumer/access token keys/secrets. Update: Applications for new Twitter API keys requires review and approval by Twitter staff now. So, this step may take some time.
  • Install python-twitter package: pip install python-twitter
  • Run python followers.py. It may be useful piping output to a file.

License

Public domain.

#!/usr/bin/env python
# 2018 (c) Omer Ozarslan,
# License: Public Domain
import twitter
api = twitter.Api(consumer_key='REPLACE_THIS',
consumer_secret='REPLACE_THIS',
access_token_key='REPLACE_THIS',
access_token_secret='REPLACE_THIS')
followers = api.GetFollowers()
print(len(followers))
for f in followers:
print(f.id, f.screen_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment