Created
May 18, 2013 05:14
-
-
Save danabauer/5603322 to your computer and use it in GitHub Desktop.
google geocoder
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
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