码迷,mamicode.com
首页 > 其他好文 > 详细

天气预报接口和城市代码

时间:2014-10-03 02:02:03      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:blog   http   strong   数据   sp   div   c   on   log   

今天在研究微信天气预报的时候,获取到json数据,后来json_decode为对象,但是去看不懂他的意思,于是百度搜索到的结果:



{ "weatherinfo": { <!-- 基本信息 --> "city":"北京", "city_en":"beijing", "date_y":"2012年8月14日", "date":"", "week":"星期二", "fchh":"18", "cityid":"101010100", <!-- 从今天开始到第六天的每天的<strong>天气</strong>情况,这里的温度是摄氏温度 --> "temp1":"19℃~31℃", "temp2":"21℃~31℃", "temp3":"22℃~28℃", "temp4":"20℃~28℃", "temp5":"21℃~29℃", "temp6":"22℃~31℃", <!-- 从今天开始到第六天的每天的<strong>天气</strong>情况,这里的温度是华氏温度 --> "tempF1":"66.2℉~87.8℉", "tempF2":"69.8℉~87.8℉", "tempF3":"71.6℉~82.4℉", "tempF4":"68℉~82.4℉", "tempF5":"69.8℉~84.2℉", "tempF6":"71.6℉~87.8℉", <!-- <strong>天气</strong>描述 --> "weather1":"阵雨转晴", "weather2":"晴", "weather3":"多云转雷阵雨", "weather4":"雷阵雨", "weather5":"多云转阴", "weather6":"雷阵雨", <!-- <strong>天气</strong>描述图片序号 --> "img1":"3", "img2":"0", "img3":"0", "img4":"99", "img5":"1", "img6":"4", "img7":"4", "img8":"99", "img9":"1", "img10":"2", "img11":"4", "img12":"99", "img_single":"0", <!-- 图片名称 --> "img_title1":"阵雨", "img_title2":"晴", "img_title3":"晴", "img_title4":"晴", "img_title5":"多云", "img_title6":"雷阵雨", "img_title7":"雷阵雨", "img_title8":"雷阵雨", "img_title9":"多云", "img_title10":"阴", "img_title11":"雷阵雨", "img_title12":"雷阵雨", "img_title_single":"晴", <!-- 风速描述 --> "wind1":"微风", "wind2":"微风", "wind3":"微风", "wind4":"微风", "wind5":"微风", "wind6":"微风", "fx1":"微风", "fx2":"微风", <!-- 风速级别描述 --> "fl1":"小于3级", "fl2":"小于3级", "fl3":"小于3级", "fl4":"小于3级", "fl5":"小于3级", "fl6":"小于3级", <!-- 今天穿衣指数 --> "index":"炎热", "index_d":"<strong>天气</strong>炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。", <!-- 48小时穿衣指数 --> "index48":"炎热", "index48_d":"<strong>天气</strong>炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。", <!-- 紫外线及48小时紫外线 --> "index_uv":"很强", "index48_uv":"强", <!-- 洗车 --> "index_xc":"较不宜", <!-- 旅游 --> "index_tr":"适宜", <!-- 舒适指数 --> "index_co":"较不舒适", "st1":"31", "st2":"17", "st3":"31", "st4":"22", "st5":"27", "st6":"22", <!-- 晨练 --> "index_cl":"适宜", <!-- 晾晒 --> "index_ls":"极适宜", <!-- 过敏 --> "index_ag":"易发" } }

 通过城市代码获取天气接口网址(返回json格式数据):

http://www.weather.com.cn/data/sk/101280102.html

http://m.weather.com.cn/data/101280102.html

http://m.weather.com.cn/atad/101230201.html

上面的三个接口偶尔会打不开,你试着那个快你用哪一个

 

通过上面的解释你可以写出自己想要发的天气预报内容。

 我把生成的所有天气代码的数组上传到解压包里了(地址):http://files.cnblogs.com/geek12/tianqi.zip

可以复制后面的连接下载

 

天气预报接口和城市代码

标签:blog   http   strong   数据   sp   div   c   on   log   

原文地址:http://www.cnblogs.com/geek12/p/4004647.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!