Skip to content

Instantly share code, notes, and snippets.

@partriv
Created June 24, 2020 01:59
Show Gist options
  • Save partriv/fd762dc5e1b03e45469502ddf7f28328 to your computer and use it in GitHub Desktop.
Save partriv/fd762dc5e1b03e45469502ddf7f28328 to your computer and use it in GitHub Desktop.
quick script to sort your follower list by who has the most follows
# get your developer keys here https://developer.twitter.com/
import twitter
api = twitter.Api(consumer_key=API_KEY,
consumer_secret=SECRET_KEY,
access_token_key=ACCESS_TOKEN,
access_token_secret=ACCESS_TOKEN_SECRET,
sleep_on_rate_limit=True)
count = -1
followers = []
next_c, prev_c, users = api.GetFollowersPaged(cursor=-1, count=200, skip_status=False, include_user_entities=True)
while next_c:
for u in users:
#print(u.screen_name)
followers.append((u.screen_name, u.followers_count, u.description, u.name))
next_c, prev_c, users = api.GetFollowersPaged(cursor=next_c, count=200, skip_status=False, include_user_entities=True)
print('------------------- SORTED FOLLOWERS -----------------------------------')
followers = sorted(followers, key=lambda x: x[1])
followers.reverse()
for f in followers:
print("name, screen name, count", f[3], f[0], f[1])
print("desc", f[2])
print("--------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment