JSON parsing from an API and do something with it: Difference between revisions
(Created page with "Using the Twitter API as an example. More particularly, we are fetching the most recent tweets containing the #cheese hashtag. See the Twitter API doc for more information. <so...") |
(No difference)
|
Revision as of 14:33, 21 January 2011
Using the Twitter API as an example. More particularly, we are fetching the most recent tweets containing the #cheese hashtag. See the Twitter 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'] + '"'