Created
May 29, 2010 06:17
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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