天天看點

天氣預報API接口

一、中央氣象台API接口:

1. XML接口

​​http://flash.weather.com.cn/wmaps/xml/china.xml​​ 這個是全國天氣的根節點,列出所有的省,其中的pyName字段是各個省XML的檔案名,比如北京的是beijing,那就意味着北京的XML位址為

​​http://flash.weather.com.cn/wmaps/xml/beijing.xml​​

一個省的天氣,其中列出該省各個市的資料,北京就列出各個區。

tmp1是最低溫低,tmp2是最高溫度,state1和state2是神馬轉神馬,每個數代表一個天氣現象。

2. 圖檔接口

​​http://m.weather.com.cn/img/c0.gif​​

​​http://m.weather.com.cn/img/b0.gif​​

​​http://www.weather.com.cn/m/i/weatherpic/29x20/d0.gif​​

​​http://www.weather.com.cn/m2/i/icon_weather/29x20/n00.gif​​

這個圖就是天氣現象0(晴)的圖檔,其他天氣現象的圖檔依此類推。c打頭的圖檔是20*20像素的,b打頭的是50*46像素的,d打頭的是反白的圖示,29*20像素,n打頭的是夜間反白圖示,29*20像素,注意這裡的檔案名是兩位數字!

3. JSON接口

​​http://m.weather.com.cn/data/101010100.html​​

​​http://www.weather.com.cn/data/sk/101010100.html​​

​​http://www.weather.com.cn/data/cityinfo/101010100.html​​

各個城市的代碼,自己百度一下。例如:北京的代碼就是101010100

二、中華萬年曆API接口:

1、JSON

​​http://wthrcdn.etouch.cn/weather_mini?city=北京​​

​​http://wthrcdn.etouch.cn/weather_mini?citykey=101010100​​

2、XML

​​http://wthrcdn.etouch.cn/WeatherApi?city=北京​​

​​http://wthrcdn.etouch.cn/WeatherApi?citykey=101010100​​

三、新浪天氣API接口:

​​http://php.weather.sina.com.cn/xml.php?city=%B9%E3%D6%DD&password=DJOYnieT8234jlsK&day=1​​

city=城市的URL編碼(廣州:%B9%E3%D6%DD)。

password固定。

day=0,表示當天天氣,1表示第二天天氣,以此類推,最大取值為4。

新浪天氣圖檔:

78*78:

白天:​​http://php.weather.sina.com.cn/images/yb3/78_78/duoyun_0.png​​

夜間:​​http://php.weather.sina.com.cn/images/yb3/78_78/duoyun_1.png​​

180*180:

白天:​​http://php.weather.sina.com.cn/images/yb3/180_180/duoyun_0.png​​