優點:資料與樣式分離
缺點:尚不完善,不支援自動檢索城市
Google code: http://code.google.com/p/weather-china/
weather-china封裝Yahoo提供的Weather RSS Feed,提供JSON格式的REST API接口,要擷取某個城市的天氣預報,例如北京,發送如下GET請求:
http://weather-china.appspot.com/api?city=beijing
參數說明:
city:城市名稱,可以使用拼音。
傳回JSON格式的字元串,使用标準的UTF-8編碼,例如:
{
"pub" : "2010-07-05 09:00",
"wind" : {
"chill" : 33,
"direction" : 340,
"speed" : 14.48
},
"astronomy" : {
"sunrise" : "4:49",
"sunset": "19:46"
},
"atmosphere" : {
"humidity" : 26,
"visibility" : 9.99,
"pressure" : 982.05,
"rising": 0
},
"forecasts" : [
{
"date" : "2010-07-05",
"day" : 1,
"code" : 32,
"text" : "晴",
"low" : 23,
"high" : 33,
"image_large" : "http://weather-china.appspot.com/static/w/img/d32.png",
"image_small" : "http://weather-china.appspot.com/static/w/img/s32.png"
},
{
"date" : "2010-07-06",
"day" : 2,
"code" : 32,
"text" : "晴",
"low" : 23,
"high" : 34,
"image_large" : "http://weather-china.appspot.com/static/w/img/d32.png",
"image_small" : "http://weather-china.appspot.com/static/w/img/s32.png"
}
]
}
pub:目前天氣資訊釋出時間;
wind:風力資訊;
astronomy:日出和日落時間;
atmosphere:大氣資訊;
forecasts:包含當天和第二天的天氣預報:
- date:日期
- day:星期
- code:天氣代碼(請在此查詢代碼含義)
- text:天氣資訊
- low:最低溫度
- high:最高溫度
- image_large:大圖檔(250x180)位址
- image_small:小圖檔(61x34)位址
天氣資訊不會頻繁更新,可以安全地在用戶端緩存1小時。
免費供個人或非營利性組織使用。