urllib.error.HTTPError: HTTP Error 404: Not Found using Google Matrix API

urllib.error.HTTPError: HTTP Error 404: Not Found using Google Matrix API

我只是想获取距离矩阵数据,但 url 似乎不起作用。 这是我的代码,我显然没有放置密钥,但这不是问题所在

import urllib.request
import json

key='x'

origin='2500+E+Kearney+Springfield+MO+65898'
destination='405+N+Jefferson+Ave+Springfield+MO+65806'

url=('https://maps.googleapis.com/maps/api/distancematrix/jason'
     +'?language=en-UK&units=metric'
     +'&origins={}'
     +'&destinations={}'
     +'&key={}'
     ).format(origin, destination, key)

response=urllib.request.urlopen(url)
response_json=json.loads(response.read())
distance_meters=response_json['rows'][0]['elements'][0]['distance']['value']
distance_minutes=response_json['rows'][0]['elements'][0]['duration']['value']/60

print("Origin: %s\nDestination: %s\nDistance (m): %s\nDuration (s): %s"
      %(origin,destination,distance_meters,round(distance_minutes,2)))

您在 url 中有错字。您想使用 https://maps.googleapis.com/maps/api/distancematrix/json 而不是 jason