how to read json from web http request of url via python urllib
I generally am looking for a quick snippet to issue an http request using urllib2 lib.
Here is a quick snippet to do so
import urllib2
import json
from pprint import pprint
req = urllib2.Request(url)
opener = urllib2.build\_opener()
f = opener.open(req)
#data varibale recieves the parsed json
data = json.loads(f.read())
print len(data)
for r in data:
pprint(r)
print "-"*50
Hope this helps
Read other posts