Created
June 15, 2014 00:04
-
-
Save kristaps/d55143917eccab56adb9 to your computer and use it in GitHub Desktop.
Google geocoder wrapper script and "library"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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