Monday, July 29, 2013

Reading API Data



In Python, this is as easy as running a couple of commands in IDLE.

from urllib import urlopen

html = urlopen("http://www.leafly.com/api/details/100-og")

html.read() 


HTTPResponse instances also have some more methods and attributes, which can be found here: http://docs.python.org/release/2.2.3/lib/httpresponse-objects.html


This can be additionally simplified by importing and using the json library.