Created
March 13, 2010 14:25
-
-
Save lxneng/331340 to your computer and use it in GitHub Desktop.
using geocoding fomarting address
This file contains hidden or 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
In [1]: import urllib | |
In [2]: import json | |
In [3]: geo_url_fomart="http://maps.google.com/maps/api/geocode/json?address=%s&sensor=true" | |
In [4]: address = "627 Masonic Ave San Francisco CA 94117" | |
In [5]: geo_fomart_address = '+'.join(address.split()) | |
In [6]: url = geo_url_fomart%geo_fomart_address | |
In [7]: url | |
http://maps.google.com/maps/api/geocode/json?address=627+Masonic+Ave+San+Francisco+CA+94117&sensor=true | |
In [8]: json_obj = json.lo | |
json.load json.loads | |
In [8]: json_obj = json.load(urllib.urlopen(url)) | |
In [9]: json_obj['results'][0]['formatted_address'] | |
Out[9]: u'627 Masonic Ave, San Francisco, CA 94117, USA' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment