Skip to content

Instantly share code, notes, and snippets.

@danabauer
Created May 18, 2013 05:14
Show Gist options
  • Save danabauer/5603322 to your computer and use it in GitHub Desktop.
Save danabauer/5603322 to your computer and use it in GitHub Desktop.
google geocoder
import simplejson
import urllib
GEOCODE_BASE_URL = 'http://maps.googleapis.com/maps/api/geocode/json'
def geocode(address,sensor, **geo_args):
geo_args.update({
'address': address,
'sensor': sensor
})
url = GEOCODE_BASE_URL + '?' + urllib.urlencode(geo_args)
result = simplejson.load(urllib.urlopen(url))
print simplejson.dumps([s['formatted_address'] for s in result['results']], indent=2)
if __name__ == '__main__':
geocode(address="San+Francisco",sensor="false")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment