好多年的帖子了~~
现在已经有了
```
def gaode_geocoder(address):
"""
高德 API:
http://lbs.amap.com/api/webservice/guide/api/georegeo """
key = "your api key"
url = "
http://restapi.amap.com/v3/geocode/geo?address=%s&output=JSON&key=%s" % (address, key)
s = requests.Session()
# 使用系统代理
s.trust_env = True
r = s.get(url, timeout=5)
# 请求结果转换为 json 对象
rep_json = r.json()
r.close()
s.close()
return rep_json
def test_gaode():
address = u"上海市浦东新区东方万国企业中心"
geocoder = gaode_geocoder(address)
# 返回值为 0 或 1,0 表示请求失败; 1 表示请求成功。
if geocoder['status'] == '1':
# "location": "116.484546,39.990064",
location = geocoder['geocodes'][0]['location']
gaode_lng = location.split(',')[0]
gaode_lat = location.split(',')[1]
print "address=%s, lng=%s, lat=%s" % (address, gaode_lng, gaode_lat)
else:
print "ERROR: status=%s, info=%s" % (geocoder['status'], geocoder['info'])
```