Skip to content

Instantly share code, notes, and snippets.

@unbracketed
Created May 29, 2010 06:17
Show Gist options
  • Save unbracketed/418082 to your computer and use it in GitHub Desktop.
Save unbracketed/418082 to your computer and use it in GitHub Desktop.
A quick and dirty script that aggregates Twitter account golden ratios using Redis to store data.
import redis
import time
import twitter
twitter = twitter.Twitter()
R = redis.Redis()
while True:
for tweet in twitter.statuses.public_timeline():
name = tweet['user']['screen_name']
followers = tweet['user']['followers_count']
friends = tweet['user']['friends_count']
count = tweet['user']['statuses_count']
print name, followers, friends, count
R.zadd("tweet_count", name, count)
R.zadd("followers", name, followers)
R.zadd("friends", name, friends)
if not friends:
R.zadd("no_friends", name, followers)
else:
R.zadd("golden_ratio", name, float(followers)/friends)
time.sleep(61)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment