Ref: https://youtu.be/sUzR3QVBKIo
ASUS X450J @ Windows 10 x 64
Visual Studio 2017 (python)
data ID
http://data.taipei/opendata/datalist/datasetMeta/outboundDesc;jsessionid=D984042CBA68D2341286C1DA0E9DE9C1?id=15c3e1ae-899b-466c-a536-208497e3a369&rid=296acfa2-5d93-4706-ad58-e83cc951863c
取得格式 (http://data.taipei/opendata/developer)
取得全部資料
您可以透過以下取得資料項目id為35aa3c53-28fb-423c-91b6-2c22432d0d70的全部內容:
http://data.taipei/opendata/datalist/apiAccess?scope=resourceAquire
&rid=35aa3c53-28fb-423c-91b6-2c22432d0d70
1. Code
import urllib.request as request
import json
src = "http://data.taipei/opendata/datalist/apiAccess?scope=resourceAquire&rid=296acfa2-5d93-4706-ad58-e83cc951863c"
with request.urlopen(src) as response:
data = json.load(response)
# 取得公司名稱列表
clist = data["result"]["results"]
with open("data.txt", "w", encoding="utf-8") as file:
for company in clist:
file.write(company["公司名稱"] + "\r\n")
2. 說明
使用 urllib / json 模組
台北市公開資料 (src)
資料首列
{"result":{"offset":0,"limit":10000,"count":5225,"sort":"","results":[{"_id":"1","統編":"04474768","公司名稱":"優鐠電子股份有限公司","公司地址":"114臺北市內湖區瑞光路258巷2號10樓","ADDR_X":"308051.826","ADDR_Y":"2774219.522"}
...
3. 結果