Hii just came across this twitter function to get tweets :-

def get_tweets()
    user='web2py'
    import urllib
    import gluon.contrib.simplejson as sj
    page = urllib.urlopen('http://twitter.com/%s?format=json' % user).read()
    tweets=XML(sj.loads(page)['#timeline'])
    return dict(tweets=tweets)

Now what I dont know is how to iterate over parse over the elements returned
as the XML object so as to have only 10 tweets instead of all the tweets .
Also please suggest if there is any other method to retrieve the tweets
using the twitter API instead of urllib.urlopen which scrapes the entire
thing.

Thanks a lot
Vivek

Reply via email to