Tracking Cuba Gooding Jr’s Twitter follower count

Happened to see Cuba Gooding Jr’s first tweet about 30 minutes or so after he created it.

At the time his profile said he had 559 followers. A few minutes later I refreshed his profile and saw the follower count had increased to 590 and every few minutes it kept increasing. By the end of the day he had about 4,000 followers.

I thought it would be interesting to track how his follower count changed going forward. So I used the Twitter API to get his follower count once per day, save the data, and then created a web page to visualize his follower count per day.

Click to open the chart which will show updated chart results


After 2 days Cuba had about 7,000 followers which averaged out to about 175 new followers per hour.  However, the number of new followers slowed down quickly to 30 or so new followers per day and after about 3 months he only gets about 10 new followers per day.  In fact, some days, he has net loss of followers, eg more people unfollow than him, than new follows on that day.

For the technically inclined, I setup an automatic retrieval of Cuba’s Tweets using Twitter’s API and the Tweepy Python module scheduled to run daily using a cron job.

The follower counts get put into a database. I created a PHP web page application to retrieve the data from the database, and create a web page that includes the Google Charts API to create a simple line chart to show Cuba’s regularly updated follower count by day.

You can get the cron job and PHP web page code from my  Github repository.  But I have also pasted the cron job Python code below. If you want to run this code yourself you will need a Twitter developer account and an OAuth file.

import tweepy
import MySQLdb
from datetime import datetime
import random
import sys, os
import json
from dateutil import tz
from tweet_auth import * #this is a .py file with the twitter api credentials
from db_cubatweet import db_cubatweet * #this is a .php file with the cubatweet db credentials
#connect to db
db = MySQLdb.connect(
    host = db_cubatweet['host'],
    db = db_cubatweet['dbname'],
    user = db_cubatweet['user'],
    passwd = db_cubatweet['password']
#create a db cursor object to execute queries
cur = db.cursor()
#get twitter auth from cred file
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
#auth.set_access_token(access_token, access_token_secret)
#call Twitter API
api = tweepy.API(auth)
#set variables to retrieve Twitter data and insert into db
users = ['cubagoodingjr']
date_zero = datetime.strptime('2016-02-11 02:35:00', '%Y-%m-%d %H:%M:%S')
date_now =
hours = 9999.99
days = round(((date_now-date_zero).total_seconds() /3600)/24,2)
#loop through Twitter API results and insert into db
for user in users:
    user_data = api.get_user(user)
    print user_data.followers_count
    cur.execute("INSERT INTO followers(user, follower_count, date, days, hours) VALUES (%s, %s, %s, %s, %s)",
        (user, user_data.followers_count, date_now, days, hours))
#create cron log entry
print, 'cubatweet'
#close db connection

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation