[英]Connection Aborted with openrouteservice
I am trying to find the distance between these two coordinates using openrouteservice and am getting the following error code.我正在尝试使用 openrouteservice 查找这两个坐标之间的距离,并收到以下错误代码。
ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
The following code was the exact example code given to me from openrouteservice, but I keep getting that error code.以下代码是 openrouteservice 给我的确切示例代码,但我一直收到该错误代码。 Also note I have removed my APIkey for security reasons.
另请注意,出于安全原因,我已经删除了我的 APIkey。 Any reasons?
有什么原因吗?
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)
You wrote:你写了:
headers = {
'Accept': 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8',
}
I am unwilling to believe the vendor specified that Accept:
header. It appears to be a pair of headers conflated together.我不愿意相信供应商指定
Accept:
header。它似乎是一对混在一起的标头。 Roughly, it is a syntax error.粗略地说,这是一个语法错误。
Try using this instead:尝试改用这个:
headers = {
'Accept': 'application/json, application/geo+json, application/gpx+xml, img/png',
'Accept-charset': 'utf-8',
}
Accept is about content types. Accept是关于内容类型的。 The various Accept-foo headers are about foo.
各种 Accept-foo 标头都是关于 foo 的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.