Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Macao Carpark 澳門公共停車場剩餘量 API with Python
# Change the following targets for your needs
targets=["栢佳", "栢湖"]
import untangle
import requests
url = "https://dsat.apigateway.data.gov.mo/car_park_maintance"
headers = {
"Authorization": "APPCODE 09d43a591fba407fb862412970667de4"
}
res = requests.get(url, headers=headers)
res.encoding="UTF-8"
data = untangle.parse(res.text)
for carpark in data.CarPark.Car_park_info:
name = carpark["name"]
car = carpark["Car_CNT"]
for target in targets:
if target in name:
print(name, car)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment