Tweepy Followers Count
September 28, 2012
In a recent forum post, one of the brass bands that I follow declared that they were the most followed brass band on twitter.
I decided to find out the facts by using a little tweepy script.
This script finds all the followers of an account (in this case bbresults
) and puts their screen name and number of followers in tuple, then adds that tuple to an array. This array is then sorted, and the results printed.
import tweepy import sys CONSUMER_KEY = "REMOVED" CONSUMER_SECRET = "REMOVED" ACCESS_TOKEN = "REMOVED" ACCESS_TOKEN_SECRET = "REMOVED" auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) api = tweepy.API(auth) user = tweepy.api.get_user('bbresults') print user.screen_name print user.friends_count lFollowers = [] for member in tweepy.Cursor(api.friends).items(): lFollowers.append((member.followers_count, member.screen_name)) lFollowers.sort() for follower in lFollowers: print "%d - %s" % (follower[0], follower[1])
It turned out they were the third most popular!