Getting users latest tweet with Django

Posted by Hanpan on Stack Overflow See other posts from Stack Overflow or by Hanpan
Published on 2010-03-19T12:59:13Z Indexed on 2010/03/19 13:01 UTC
Read the original article Hit count: 246

Filed under:

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

© Stack Overflow or respective owner

Related posts about django