Created
December 22, 2021 16:29
-
-
Save makzan/c02d35dcf5bd13760255fc1d9580b621 to your computer and use it in GitHub Desktop.
Macao Carpark 澳門公共停車場剩餘量 API with Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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