JSON parsing from an API and do something with it
Revision as of 14:37, 21 January 2011 by Aymeric Mansoux (talk | contribs)
Using the Twitter API as an example. More particularly, we are fetching the most recent tweets containing the #cheese hashtag. See the API doc for more information.
import urllib2, json
url = 'http://search.twitter.com/search.json?q=%23cheese'
f = urllib2.urlopen(url)
data = json.load(f)
for r in data['results']:
print r['from_user'] + ' says "' + r['text'] + '"'