Files
004_comission/vihuwach/task1/archive/task1_fufill_answer.py
louiscklaw 6c95c5e3ea update,
2025-01-31 21:57:33 +08:00

21 lines
503 B
Python

# https://api.data.gov.hk/v1/carpark-info-vacancy?data=vacancy&vehicleTypes=privateCar
import requests
from pprint import pprint
url = "https://api.data.gov.hk/v1/carpark-info-vacancy"
response = requests.get(url)
js_result = response.json()['results']
js_row = js_result[0]
pprint(js_row)
pprint("length of json: "+str(len(js_result)))
import json
# Store js_result into js_result.json
with open('js_result.json', 'w') as outfile:
json.dump(js_result, outfile, indent=2)