中国国家气象局天气预报接口总共提供了三个:
http://www.weather.com.cn/data/sk/101010100.html
http://www.weather.com.cn/data/cityinfo/101010100.html
http://m.weather.com.cn/data/101010100.html
其中,最详细的信息来自第三个接口。上面url中的101010100是城市代码,这里是北京的城市代码。只需要改变城市代码,就可以得到所在城市的天气信息。
如,武汉的城市代码是101200101,所以所需要的url应该为 http://m.weather.com.cn/data/101200101.html,从而就可以读到天气的信息。
天气信息的数据结构是json,数据如下:
{"weatherinfo":{"city":"武汉","city_en":"wuhan","date_y":"2012年7月2日","date":"","week":"星期一","fchh":"11","cityid":"101200101","temp1":"35℃~27℃","temp2":"34℃~27℃","temp3":"34℃~27℃","temp4":"35℃~27℃","temp5":"35℃~27℃","temp6":"35℃~28℃","tempF1":"95℉~80.6℉","tempF2":"93.2℉~80.6℉","tempF3":"93.2℉~80.6℉","tempF4":"95℉~80.6℉","tempF5":"95℉~80.6℉","tempF6":"95℉~82.4℉","weather1":"多云","weather2":"多云","weather3":"多云","weather4":"多云","weather5":"多云","weather6":"多云","img1":"1","img2":"99","img3":"1","img4":"99","img5":"1","img6":"99","img7":"1","img8":"99","img9":"1","img10":"99","img11":"1","img12":"99","img_single"