---
title: "開放源碼香港天氣計劃 hk0weather"
url: https://sammy.hk/opensource-hk0weather/
author: Sammy Fung
published: 2013-02-14T10:00:29+08:00
modified: 2020-02-15T03:05:05+08:00
description: "昨晚半夜終於第一次放 source code 上 github，hk0weather 是其中一個我打算拿出來 open source 的 projects。把 hk0weather 開放源碼的其中一個原因是，希望幫助打造香港的 Open Data 之類，實在忍不了香港某方那些所謂 (很爛的) Open Data 的格式…"
categories: ["開放源碼"]
tags: ["開放源碼"]
source: https://sammy.hk
---
昨晚半夜終於第一次放 source code 上 github，[hk0weather](https://github.com/sammyfung/hk0weather) 是其中一個我打算拿出來 open source 的 projects。把 hk0weather 開放源碼的其中一個原因是，希望幫助打造香港的 Open Data 之類，實在忍不了香港某方那些所謂 (很爛的) Open Data 的格式。同時我也欣賞台灣的 [g0v.tw](http://g0v.tw) 的工作，一直我也對一些政府或公共資料該如何公開 (open data) 有些意見 (提議)，而由民間或社群來進行也是其中一個可取的方法，來帶動香港的 open data 發展。

第一個版本是把香港天文台的天氣報告，把各氣象站的溫度，以及香港天文台錄得的相對濕度，轉化以 json 資料或其他格式。基本上已足夠一般網站，從輸出 json 資料中取得香港氣溫來顯示。

hk0weather 是以 python 來編寫，利用 scrapy 作 web crawling 的 framework。以下是未經測試的使用例子。

$ virtualenv hk0weatherenv
$ source hk0weatherenv/bin/activate
$ pip install scrapy
$ git clone https://github.com/sammyfung/hk0weather.git
$ cd hk0weather
$ scrapy crawl currwx -t json -o testresult

以下是測試結果的 json 輸出。

\[{“humidity”: 80, “station”: “hko”, “temperture”: 17, “time”: 1360785720},
{“station”: “kingspark”, “temperture”: 16, “time”: 1360785720},
{“station”: “wongchukhang”, “temperture”: 17, “time”: 1360785720},
{“station”: “takwuling”, “temperture”: 16, “time”: 1360785720},
{“station”: “laufaushan”, “temperture”: 15, “time”: 1360785720},
{“station”: “taipo”, “temperture”: 16, “time”: 1360785720},
{“station”: “shatin”, “temperture”: 17, “time”: 1360785720},
{“station”: “tuenmun”, “temperture”: 17, “time”: 1360785720},
{“station”: “tseungkwano”, “temperture”: 16, “time”: 1360785720},
{“station”: “saikung”, “temperture”: 16, “time”: 1360785720},
{“station”: “cheungchau”, “temperture”: 17, “time”: 1360785720},
{“station”: “cheungchau”, “temperture”: 17, “time”: 1360785720},
{“station”: “tsingyi”, “temperture”: 17, “time”: 1360785720},
{“station”: “shekkong”, “temperture”: 15, “time”: 1360785720},
{“station”: “tsuenwanhokoon”, “temperture”: 15, “time”: 1360785720},
{“station”: “tsuenwanshingmunvalley”, “temperture”: 17, “time”: 1360785720},
{“station”: “hongkongpark”, “temperture”: 17, “time”: 1360785720},
{“station”: “shaukeiwan”, “temperture”: 16, “time”: 1360785720},
{“station”: “kowlooncity”, “temperture”: 16, “time”: 1360785720},
{“station”: “happyvalley”, “temperture”: 18, “time”: 1360785720},
{“station”: “wongtaisin”, “temperture”: 17, “time”: 1360785720},
{“station”: “stanley”, “temperture”: 16, “time”: 1360785720},
{“station”: “kwuntong”, “temperture”: 15, “time”: 1360785720},
{“station”: “shamshuipo”, “temperture”: 17, “time”: 1360785720}\]

hk0weather 計劃未來除了會慢慢加入更多不同的氣象資料外，也打算跟一些比我更 pro 的氣象發燒友合作。而 hk0weather 這個 open source 版本是我另外重寫的，跟我在 twitter 的 [@weatherhk](http://sammy.hk/2009/06/09/metropop-twitter-weatherhk-interview) 背後所運行的 python 程式有所不同。

### 相關文章：

1. [設定 github 帳號的 git ssh key](https://sammy.hk/%e8%a8%ad%e5%ae%9a-github-%e5%b8%b3%e8%99%9f%e7%9a%84-git-ssh-key/ "設定 github 帳號的 git ssh key")
2. [自製港鐵即時班次資料一頁過](https://sammy.hk/%e8%87%aa%e8%a3%bd%e6%b8%af%e9%90%b5%e5%8d%b3%e6%99%82%e7%8f%ad%e6%ac%a1%e8%b3%87%e6%96%99%e4%b8%80%e9%a0%81%e9%81%8e/ "自製港鐵即時班次資料一頁過")
3. [參與開放源碼本應的模式](https://sammy.hk/%e5%8f%83%e8%88%87%e9%96%8b%e6%94%be%e6%ba%90%e7%a2%bc%e6%9c%ac%e6%87%89%e7%9a%84%e6%a8%a1%e5%bc%8f/ "參與開放源碼本應的模式")
4. [Hacktoberfest 2020](https://sammy.hk/hacktoberfest-2020/ "Hacktoberfest 2020")
