Skip to content

Instantly share code, notes, and snippets.

@kristaps
Created June 15, 2014 00:04
Show Gist options
  • Save kristaps/d55143917eccab56adb9 to your computer and use it in GitHub Desktop.
Save kristaps/d55143917eccab56adb9 to your computer and use it in GitHub Desktop.
Google geocoder wrapper script and "library"
#!/usr/bin/env python
import urllib
import json
def geocode(address):
return json.loads(urllib.urlopen(
"http://maps.googleapis.com/maps/api/geocode/json?address=%s" % (
urllib.quote(address.encode('utf-8')))
).read())
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('address')
args = parser.parse_args()
print json.dumps(geocode(args.address.decode('utf-8')), indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment