Created
August 24, 2011 12:22
Script to get trending topics on Twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import simplejson | |
import urllib2 | |
from pprint import pprint | |
req = urllib2.Request('https://api.twitter.com/1/trends/1.json') | |
opener = urllib2.build_opener() | |
f = opener.open(req) | |
json = simplejson.load(f) | |
#print simplejson.dumps(json, indent=1) | |
trends = [trend['name'] for trend in json[0]['trends']] | |
pprint(trends) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment