Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View geocode.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
"""Write a script that uses a google maps json response to collect the street address
city, state and postal code of Noisebridge"""
 
import urllib2
import json
 
coords = '37.762632,-122.419433'
url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='+coords+'&sensor=false'
 
response = urllib2.urlopen(url)
html = response.read()
 
webster = json.loads(html)
add_list = []
 
"""
for item in webster['results'][0]['address_components']:
add_list.append(item['long_name'])
 
for item in add_list:
print item
"""
 
numberAdd = webster['results'][0]['address_components'][0]['long_name']
street = webster['results'][0]['address_components'][1]['long_name']
city = webster['results'][0]['address_components'][3]['long_name']
state = webster['results'][0]['address_components'][5]['long_name']
country = webster['results'][0]['address_components'][6]['long_name']
zipcode = webster['results'][0]['address_components'][7]['long_name']
 
print(numberAdd+' '+street+' '+city+','+' '+state+' '+zipcode+' '+country)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.