#!/usr/bin/env python2.6
"""
Get some JSON data from a URL passed on the commandline
Public Domain
"""
import urllib2
import json
import sys
def getJSONPage( url ):
"""
Get the JSON response from a url
"""
data = urllib2.urlopen(url).read()
return json.loads(data)
if __name__ == '__main__':
if len(sys.argv) > 1:
for url in sys.argv[1:]:
print "FROM: %s" % (url)
print getJSONPage(url)
else:
print "Usage: %s <URL>" % (sys.argv[0])Add a code snippet to your website: www.paste.org