臺北市垃圾車點位路線資訊
資料來源:臺北市資料大平台https://data.taipei/api/v1/dataset/a6e90031-7ec4-4089-afb5-361a4efe7202?scope=resourceAquire
import urllib.request as request
import json
x = "https://data.taipei/api/v1/dataset/a6e90031-7ec4-4089-afb5-361a4efe7202?scope=resourceAquire"
with request.urlopen(x) as response:
data = json.load(response)
print(data)
taipei_list = data["result"]["results"]
print(len(taipei_list))
with open("taipei_garbage.txt", "w", encoding= "utf-8") as file:
for clist in taipei_list:
place = clist.get("里別")
location = clist.get("地點")
arrive_time = clist.get("抵達時間")
leave_time = clist.get("離開時間")
print("------------------------")
output_data = (f" {"里別"}:{place}\n {"地點"}:{location}\n {"抵達時間"}:{arrive_time}\n {"離開時間"}:{leave_time}\n"
f"------------------------")
print(output_data)
file.write(output_data + "\n")
里別:力行里
地點:臺北市中山區建國北路1段69號前
抵達時間:1630
離開時間:1638
------------------------
里別:力行里
地點:臺北市中山區南京東路3段176號前(遼寧街口)
抵達時間:1640
離開時間:1649
------------------------
里別:力行里
地點:臺北市中山區南京東路3段214號前
抵達時間:1650
離開時間:1658
(下略)
沒有留言:
張貼留言