← ClaudeAtlas

taiwan-toiletlisted

全國公廁查詢——環境部全國公廁建檔資料(位置、管理單位、評鑑等級、尿布台)。附近公廁、哪裡有廁所、乾淨的公廁的問題適用。免註冊——用政府資料開放平臺公布的公用資料集存取金鑰。即時開放狀態(維修中)不適用。
tahodev/baodao-skill · ★ 1 · AI & Automation · score 77
Install: claude install-skill tahodev/baodao-skill
# taiwan-toilet > 實測日:2026-09-19(最近一次端對端實測;數值基準日各自標於內文) 查環境部「全國公廁建檔資料」(data.gov.tw 資料集 30794)的公廁位置與評鑑。**不用自己註冊**:data.gov.tw 資料集頁公布了該資料集的 API 存取金鑰,直接用即可。 ## 基本流程 1. 帶公布金鑰抓 API(分頁 limit=1000,用 offset 翻頁) 2. 依縣市代碼、鄉里、經緯度篩選 3. 回報名稱、地址、管理單位、評鑑等級;有經緯度可算最近公廁 ### 1. 抓資料 ```bash BASE='https://data.moenv.gov.tw/api/v2/fac_p_07?api_key=b7df779e-71a6-4148-8379-5afbd441d803' curl -sm 30 -A 'Mozilla/5.0' "$BASE&limit=1000&offset=0&sort=ImportDate%20desc&format=JSON" -o /tmp/toilet_p1.json curl -sm 30 -A 'Mozilla/5.0' "$BASE&limit=1000&offset=1000&sort=ImportDate%20desc&format=JSON" -o /tmp/toilet_p2.json ``` 2026-09-19 實測:HTTP 200、每頁 1,000 筆,offset 翻頁正常;回傳筆數 < limit 即到底。欄位:county(縣市代碼,如 65000=新北市、10018=新竹市)、areacode、village、number、name、address、administration(管理單位)、latitude/longitude、grade(評鑑等級:特優級、優等級…)、type/type2(公廁類型)、exec、diaper(尿布台)。 實測範例:「中油鶯歌加油站-男廁」(新北市鶯歌區南靖里文化路 152 號,台灣中油管理,特優級,24.9504, 121.3522)。 ### 2. 縣市代碼 county 欄是內政部代碼(65000=新北市、10018=新竹市…)。沒有文字縣市名,**用 address 前幾個字判斷縣市更直覺**,或對照代碼表。 ### 3. 找最近公廁 ```python import json, math rows = json.load(open('/tmp/toilet_p1.json')) def dist(la1, lo1, la2, lo2): return math.hypot((la1-la2)*111, (lo1-lo2)*111*math.cos(math.radians(la1))) # km 粗估 near = sorted((dist(25.04,121.51,float(r['latitude']),float(r['longitude'])), r) for r in rows if r['latitude']) for d, r in near[:3]: print(f"{d:.2f}km {r['name']} {r['address']} {r['grade']}") ``` ## 錯誤與失敗時的處理 - **金鑰是 data.gov.tw 公布的資料集金鑰**:從資料集 30794 頁面的 resource URL 取得;若失效(40