你可以從Python中使用json
和requests
庫,並使用postman
(一個應用程序來幫助你看到的JSON/API的)。這些操作嵌套在routes
- >legs
- >steps
內,因此您可以迭代json
中位於data["routes"][0]["legs"][0]["steps"]
處的對象的每個對象。這裏有一些你可以用來幫助你入門的工作代碼。充分利用它來滿足您的需求。
import json
import requests
url = 'https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood4&key=AIzaSyDFZyV9E89I3L0Gt9A67DplLpZEq2F1G00'
data = requests.get(url).json()
def get_maneuvers():
"returns a list of maneuvers and displays each one in list"
steps = []
for step in data["routes"][0]["legs"][0]["steps"]:
if "maneuver" in step:
print step["maneuver"]
steps.append(step["maneuver"])
return steps
get_maneuvers()
不幸的是,有人已經回覆了您的免費工作要求。然而,我想象4個降價和即將關閉將表明這種問題在這裏不受歡迎。我們需要海報在這裏努力。 – halfer