23 lines
516 B
Python
23 lines
516 B
Python
import requests
|
|
|
|
|
|
def get_models_for_make():
|
|
make = "honda"
|
|
url = (
|
|
f"https://vpic.nhtsa.dot.gov/api/vehicles/GetModelsForMake/{make}/?format=json"
|
|
)
|
|
|
|
resp = requests.get(url)
|
|
|
|
if resp.status_code == 200:
|
|
results = resp.json()
|
|
return results["Results"]
|
|
else:
|
|
print(f"Error: {resp.status_code}")
|
|
return {"Error": f"Request failed with status code {resp.status_code}"}
|
|
|
|
|
|
models = get_models_for_make()
|
|
for model in models:
|
|
print(model["Model_Name"])
|