我正试图使用openrouteservice找到这两个坐标之间的距离,并得到以下错误代码。
ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))下面的代码是openrouteservice提供给我的具体示例代码,但我一直得到错误代码。还请注意,出于安全原因,我已经删除了我的APIkey。有什么原因吗?
import requests
headers = {
'Accept': 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8',
}
call = requests.get('https://api.openrouteservice.org/v2/directions/driving-car?api_key=APIKEYHERE&start=8.681495,49.41461&end=8.687872,49.420318', headers=headers)
print(call.status_code, call.reason)
print(call.text)发布于 2022-10-05 19:32:06
你写道:
headers = {
'Accept': 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8',
}我不愿意相信供应商指定了Accept:头。它似乎是一对合并在一起的标题。大致来说,这是一个语法错误。
试着用这个代替:
headers = {
'Accept': 'application/json, application/geo+json, application/gpx+xml, img/png',
'Accept-charset': 'utf-8',
}接受是关于内容类型的。各种Accept-foo头都是关于foo的。
https://stackoverflow.com/questions/73965136
复制相似问题