对Google地理编码API的普通HTTP API调用在Python请求模块中失败

对Google地理编码API的普通HTTP API调用在Python请求模块中失败,python,google-maps,ssl,google-geocoding-api,Python,Google Maps,Ssl,Google Geocoding Api,我在一个公司代理中,所以经常会遇到SSL问题,不得不求助于普通HTTP(当它不涉及敏感数据时)。因此,我正在尝试通过普通HTTP进行地理标记。当我创建一个调用并在终端上使用curl执行它时,我得到了预期的JSON响应。但是,当我将相同的URL放在Python脚本中并使用请求点击URL.get时,我得到了一个SSL错误: {u'status': u'REQUEST_DENIED', u'error_message': u'Requests to this API must be over SSL.

我在一个公司代理中,所以经常会遇到SSL问题,不得不求助于普通HTTP(当它不涉及敏感数据时)。因此,我正在尝试通过普通HTTP进行地理标记。当我创建一个调用并在终端上使用
curl
执行它时,我得到了预期的JSON响应。但是,当我将相同的URL放在Python脚本中并使用
请求点击URL.get
时,我得到了一个SSL错误:

{u'status': u'REQUEST_DENIED', u'error_message': u'Requests to this API must be over SSL.', u'results': []}
Python非常简单,但这是为子孙后代准备的:

import json
import requests

response = requests.get('http://maps.googleapis.com/maps/api/geocode/json?address=some+address+here&key=my-key')
json_data = json.loads(response.text)

print json_data
当然,如果我尝试使用HTTPS调用,我会遇到代理证书错误。有什么想法吗


更新:


我知道我可以将
verify=false
标志添加到
requests
方法调用中,以克服SSL证书问题,但这并不能帮助我理解为什么调用会从API上反弹,即使它表面上接受普通的HTTP调用。

您应该使用HTTPs协议来处理请求

import json
import requests

response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address=some+address+here&key=my-key')
json_data = json.loads(response.text)

print json_data
来自Google的示例url:

给予

{u'status':u'OK',u'results':[{u'geometry':{u'location':{u'lat':37.422245,u'lng':-122.0840084},u'viewport':{u'northern':{u'lat 37.42359398029149,u'lng':-122.0826594197085},u'lat 37.4208960197085,u'lng':-122.0853573802915},u'location,u'type,u'roof'station':u'[{u'long_name':u'1600',u'types':[u'street_number',u'short_name':u'1600'},{u'long_name':u'arphithere Parkway',u'types':[u'route'],u'short_name':u'arphithere Pkwy',{u'long_name':u'Mountain View',u'types':[u'locality',u'political',u'short_'u'u'name':u'Mountain''.},{u'Santa Clara'types''[u'Administration_area_level_2',u'political',u'short_name':u'Santa Clara County',u'long_name':u'California',u'types:[u'Administration_area_level_1',u'political',u'short_name':u'CA',u'long_name':u'United States',u'types:[u'country',u'political',u'u's',u'short_name':u'u'u'long_'u'u'u'u'name':u'94043',邮政编码],u'short_name':u'94043'}],u'place_id':u'ChIJ2eUgeAK6j4ARbn5u_wAGqWA',u'formatted_address':u'1600圆形剧场Pkwy,Mountain View,CA 94043,USA',u'types':[u'street_address']}


我知道这些API调用应该通过HTTPS进行。但是,正如我在我的OP中所述,我遇到了代理/证书问题,这导致我尝试通过普通HTTP进行调用。API的文档说明这是可能的:“要通过HTTP访问谷歌地图地理编码API,请使用:
http://maps.googleapis.com/maps/api/geocode/output?parameters
”。