一、天气预报接口汇总:(2014-10-08工作小结)
1.天气实况信息http://www.weather.com.cn/data/sk/101010100.html(加粗倾斜部分为请求城市编码,“101010100”=“北京”)
返回信息为JSON数据:
{"weatherinfo":{"city":"北京","cityid":"101010100","temp":"19","WD":"东风","WS":"2级","SD":"67%","WSE":"2","time":"14:35","isRadar":"1","Radar":"JC_RADAR_AZ9010_JB","njd":"暂无实况","qy":"1016"}}
上面的JSON数据图解
图1.2注:此地址返回的天气实况信息不包括1.2中的“预警”、“空气质量”、“尾号限行”三部分。选择使用此地址请注意。
2.24小时(白天和夜晚)天气信息http://www.weather.com.cn/data/cityinfo/101010100.html(加粗倾斜部分为请求城市编码,“101010100”=“北京”)
返回的JSON数据:
{"weatherinfo":{"city":"北京","cityid":"101010100","temp1":"22℃","temp2":"13℃","weather":"霾转晴","img1":"d53.gif","img2":"n0.gif","ptime":"11:00"}}
上面的JSON数据图解:
图2.2注:此地址返回的24小时天气信息不包括2.2中的日出日落时间。
3.各种淡疼指数信息http://www.weather.com.cn/data/zs/101010100.html,此JSON数据分析跳过。
上面三个请求返回的数据太分散,有的不是我想要的,有的是我想要但是没提供。。。你通过给出的三个地址可以看出数据提供方是“中国天气网”,下面给出一个比较全面的天气信息请求地址,但是不是“中国天气网”提供的,网上搜索得到的,本人不对其服务质量和数据可靠性承担任何责任。
4.http://wthrcdn.etouch.cn/weather_mini?citykey=101010100
或者http://wthrcdn.etouch.cn/weather_mini?city=北京
对比两个地址的不同部分可以看出一个是通过citykey,一个是通过city中文名获取该城市的天气预报信息。
返回的JSON数据:
{"desc":"OK","status":1000,"data":{"wendu":"15","ganmao":"各项气象条件适宜,无明显降温过程,发生感冒机率较低。","forecast":[{"fengxiang":"微风","fengli":"小于3级","high":"高温 22℃","type":"晴","low":"低温 13℃","date":"8日星期三"},{"fengxiang":"微风","fengli":"小于3级","high":"高温 23℃","type":"晴","low":"低温 13℃","date":"9日星期四"},{"fengxiang":"微风","fengli":"小于3级","high":"高温 19℃","type":"多云","low":"低温 14℃","date":"10日星期五"},{"fengxiang":"微风","fengli":"小于3级","high":"高温 18℃","type":"阵雨","low":"低温 10℃","date":"11日星期六"},{"fengxiang":"微风","fengli":"小于3级","high":"高温 17℃","type":"多云","low":"低温 6℃","date":"12日星期日"},{"fengxiang":"微风","fengli":"小于3级","high":"高温 17℃","type":"晴","low":"低温 5℃","date":"13日星期一"},{"fengxiang":"微风","fengli":"小于3级","high":"高温 19℃","type":"晴","low":"低温 7℃","date":"14日星期二"}],"yesterday":{"fl":"小于3级","fx":"微风","high":"高温 18℃","type":"晴","low":"低温 11℃","date":"7日星期二"},"aqi":"250","city":"北京"}}
5.数据最全面的一个http://wthrcdn.etouch.cn/WeatherApi?citykey=101010100,返回数据为XML格式(上面四种均为JSON格式)。