Getting users latest tweet with Django
- by Hanpan
I want to create a function which grabs every users latest tweet from a specific group. So, if a user is in the 'authors' group, I want to grab their latest tweet and then finally cache the result for the day so we only do the crazy leg work once.
def latest_tweets(self):
g = Group.objects.get(name='author')
users = []
for u in g.user_set.all():
acc = u.get_profile().twitter_account
users.append('http://twitter.com/statuses/user_timeline/'+acc+'.rss')
return users
Is where I am at so far, but I'm at a complete loose end as to how I parse the RSS to get there latest tweet. Can anyone help me out here? If there is a better way to do this, any suggestions are welcome! I'm sure someone will suggest using django-twitter or other such libraries, but I'd like to do this manually if possible.
Cheers