21 lines
503 B
Python
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)
|