wrongmove/crawler/proof_of_concept/routing_distancematrix.py

23 lines
544 B
Python
Raw Normal View History

2024-01-29 01:09:56 +00:00
import requests
2024-03-25 20:48:48 +00:00
API_KEY = "AIzaSyBoBHzeQFgR7O-NlNsuHXQcC1B7ccEHpl8"
2024-01-29 01:09:56 +00:00
url = "https://maps.googleapis.com/maps/api/distancematrix/json"
2024-03-25 20:48:48 +00:00
origin = "51.5636306598907,-0.11061106079085892"
2024-01-29 01:09:56 +00:00
dest = "51.53836609846008,-0.12743940233824352"
params = {
2024-03-25 20:48:48 +00:00
"origins": origin,
"destinations": dest,
"key": API_KEY,
"departure_time": "", # timstamp, optional
"mode": "transit",
2024-01-29 01:09:56 +00:00
}
r = requests.get(url, params=params)
print(r.status_code)
print(r.json())
2024-03-25 20:48:48 +00:00
with open("code/json/routing_distancematrix.json", "w") as f:
f.write(r.text)