Implemented a trending topics search function. Returns an array of dictionary items to loop through - fairly snazzy.

This commit is contained in:
Ryan McGrath 2009-05-05 02:19:39 -04:00
parent 91fc174fdc
commit f2553f81dc

View file

@ -26,8 +26,10 @@ class tango:
return formattedTimeline return formattedTimeline
def getTrendingTopics(self): def getTrendingTopics(self):
# Returns an array of dictionary items containing the current trends
trendingTopicsURL = "http://search.twitter.com/trends.json" trendingTopicsURL = "http://search.twitter.com/trends.json"
trendingTopics = simplejson.load(urllib.urlopen(trendingTopicsURL)) trendingTopics = simplejson.load(urllib.urlopen(trendingTopicsURL))
pass # for now, coming soon trendingTopicsArray = []
for topic in trendingTopics['trends']:
trendingTopicsArray.append({"name" : topic['name'], "url" : topic['url']})
return trendingTopicsArray