From f2553f81dcb204733ea62cbdc8ce9ae3a0766bf6 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Tue, 5 May 2009 02:19:39 -0400 Subject: [PATCH] Implemented a trending topics search function. Returns an array of dictionary items to loop through - fairly snazzy. --- tango.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tango.py b/tango.py index c3d631e..763049e 100644 --- a/tango.py +++ b/tango.py @@ -26,8 +26,10 @@ class tango: return formattedTimeline def getTrendingTopics(self): + # Returns an array of dictionary items containing the current trends trendingTopicsURL = "http://search.twitter.com/trends.json" 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