转自:http://blog.csdn.net/fancylovejava/article/details/26102635
我只想说现在网上那几个api完全坑爹有木有???
官方的申请不来有木有,还有收费有木有??
咱这种菜鸟只能用免费的了!!!!
http://m.weather.com.cn/data/101110101.html
大坑有木有??反应慢不说了,还老不更新!!
想贴段代码的,现在又打不开了(貌似3月4号以后没更新过)
==========================我是分割线==========================
下面,正式开始本次主题!!!
http://www.weather.com.cn/data/sk/101010100.html
{"weatherinfo":{"city":"北京","cityid":"101010100","temp":"22","WD":"北风","WS":"2级","SD":"19%","WSE":"2","time":"16:05","isRadar":"1","Radar":"JC_RADAR_AZ9010_JB"}}
http://www.weather.com.cn/data/cityinfo/101010100.html
{"weatherinfo":{"city":"北京","cityid":"101010100","temp1":"24℃","temp2":"11℃","weather":"雷阵雨转多云","img1":"d4.gif","img2":"n1.gif","ptime":"11:00"}}
这俩都见过吧
反正数据就是这样,也没啥好说的,但是只有实时天气,实在不爽,想做个天气应用怎么也得有未来天气,指数啥的吧!!
http://www.weather.com.cn/data/zs/101010100.html
说:你看到了啥,不错上面地址就是天气指数各种详细,还是json数据,各种好用!!!
还不够???对啊未来天气怎么办???刚才那个m.weather.com.cn.....挂掉了没办法啊!!!但是数据总会有的,不要灰心!!
==================================我是分割线============================================================
真正的重点,今天去中华万年历的时候不小心抓包就抓到了一个网址,打开一看碉堡了!!!通过对比,和中国天气同步!!!!
{"desc":"OK","status":1000,"data":{"wendu":"22","ganmao":"风较大,较易发生感冒,注意防护。","forecast":[{"fengxiang":"北风","fengli":"5-6级","high":"高温 24℃","type":"晴","low":"低温 11℃","date":"3日星期六"},{"fengxiang":"北风","fengli":"4-5级","high":"高温 19℃","type":"晴","low":"低温 8℃","date":"4日星期日"},{"fengxiang":"无持续风向","fengli":"微风","high":"高温 21℃","type":"晴","low":"低温 9℃","date":"5日星期一"},{"fengxiang":"无持续风向","fengli":"微风","high":"高温 21℃","type":"多云","low":"低温 10℃","date":"6日星期二"},{"fengxiang":"无持续风向","fengli":"微风","high":"高温 24℃","type":"晴","low":"低温 12℃","date":"7日星期三"},{"fengxiang":"无持续风向","fengli":"微风","high":"高温 23℃","type":"晴","low":"低温 11℃","date":"8日星期四"}],"yesterday":{"fl":"微风","fx":"无持续风向","high":"高温 23℃","type":"晴","low":"低温 12℃","date":"2日星期五"},"aqi":"59","city":"北京"}}
有没有很爽的感觉???对json数据,未来七天的天气。。。全了!!!
包含实时气温,感冒指数,未来七天天气(风力,风向,高低温,时间),空气质量指数(有的城市没有),城市名称
下面贴地址!!!!
通过城市名字获得天气数据,json数据
http://wthrcdn.etouch.cn/weather_mini?citykey=101010100
通过城市id获得天气数据,json数据
如果这还不够!!!下面还有!!!!
<resp> <city>北京</city> <updatetime>16:10</updatetime> <wendu>23</wendu> <fengli>3级</fengli> <shidu>19%</shidu> <fengxiang>北风</fengxiang> <sunrise_1/> <sunset_1/> <sunrise_2/> <sunset_2/> <environment> <aqi>59</aqi> <pm25>30</pm25> <suggest>极少数敏感人群应减少户外活动</suggest> <quality>良</quality> <MajorPollutants>颗粒物(PM10)</MajorPollutants> <o3>93</o3> <co>0</co> <pm10>67</pm10> <so2>8</so2> <no2>25</no2> <time>15:00:00</time> </environment> <alarm> <cityKey>10101</cityKey> <cityName> <![CDATA[ 北京市 ]]> </cityName> <alarmType> <![CDATA[ 大风 ]]> </alarmType> <alarmDegree> <![CDATA[ 蓝色 ]]> </alarmDegree> <alarmText> <![CDATA[ 北京市气象台发布大风蓝色预警 ]]> </alarmText> <alarm_details> <![CDATA[ 预计,3日下午到夜间,本市大部分地区将出现6级以上大风,阵风7-8级,请注意防范。 ]]> </alarm_details> <standard> <![CDATA[ 24小时内可能受大风影响,平均风力可达6级以上,或者阵风7级以上;或者已经受大风影响,平均风力为6~7级,或者阵风7~8级并可能持续。 ]]> </standard> <suggest> <![CDATA[ 1.政府及相关部门按照职责做好防大风工作;2.关好门窗,加固围板、棚架、广告牌等易被风吹动的搭建物,妥善安置易受大风影响的室外物品,遮盖建筑物资;3.相关水域水上作业和过往船舶采取积极的应对措施,如回港避风或者绕道航行等;4.行人注意尽量少骑自行车,刮风时不要在广告牌、临时搭建物等下面逗留;5.有关部门和单位注意森林、草原等防火。 ]]> </suggest> <imgUrl> <![CDATA[ http://www.weather.com.cn/m2/i/about/alarmpic/0501.gif ]]> </imgUrl> <time>2014-05-03 12:51:14</time> </alarm> <yesterday> <date_1>2日星期五</date_1> <high_1>高温 23℃</high_1> <low_1>低温 12℃</low_1> <day_1> <type_1>晴</type_1> <fx_1>无持续风向</fx_1> <fl_1>微风</fl_1> </day_1> <night_1> <type_1>晴</type_1> <fx_1>无持续风向</fx_1> <fl_1>微风</fl_1> </night_1> </yesterday> <forecast> <weather> <date>3日星期六</date> <high>高温 24℃</high> <low>低温 11℃</low> <day> <type>晴</type> <fengxiang>北风</fengxiang> <fengli>5-6级</fengli> </day> <night> <type>多云</type> <fengxiang>北风</fengxiang> <fengli>5-6级</fengli> </night> </weather> <weather> <date>4日星期日</date> <high>高温 19℃</high> <low>低温 8℃</low> <day> <type>晴</type> <fengxiang>北风</fengxiang> <fengli>4-5级</fengli> </day> <night> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </night> </weather> <weather> <date>5日星期一</date> <high>高温 21℃</high> <low>低温 9℃</low> <day> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </day> <night> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </night> </weather> <weather> <date>6日星期二</date> <high>高温 21℃</high> <low>低温 10℃</low> <day> <type>多云</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </day> <night> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </night> </weather> <weather> <date>7日星期三</date> <high>高温 24℃</high> <low>低温 12℃</low> <day> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </day> <night> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </night> </weather> <weather> <date>8日星期四</date> <high>高温 23℃</high> <low>低温 11℃</low> <day> <type>晴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </day> <night> <type>阴</type> <fengxiang>无持续风向</fengxiang> <fengli>微风</fengli> </night> </weather> </forecast> <zhishus> <zhishu> <name>感冒指数</name> <value>较易发</value> <detail>风较大,较易发生感冒,注意防护。</detail> </zhishu> <zhishu> <name>紫外线</name> <value>弱</value> <detail>辐射较弱,涂擦SPF12-15、PA+护肤品。</detail> </zhishu> <zhishu> <name>穿衣指数</name> <value>较冷</value> <detail>建议着厚外套加毛衣等服装。</detail> </zhishu> <zhishu> <name>舒适度</name> <value>舒适</value> <detail>白天不冷不热,风力不大。</detail> </zhishu> <zhishu> <name>洗车指数</name> <value>不宜</value> <detail>有雨,雨水和泥水会弄脏爱车。</detail> </zhishu> <zhishu> <name>旅游指数</name> <value>一般</value> <detail>有降水,风稍大,外出注意防雷防风。</detail> </zhishu> <zhishu> <name>运动指数</name> <value>较不宜</value> <detail>有降水,推荐您在室内进行休闲运动。</detail> </zhishu> <zhishu> <name>晨练指数</name> <value>较不宜</value> <detail>室外锻炼请携带雨具。</detail> </zhishu> <zhishu> <name>约会指数</name> <value>不适宜</value> <detail>建议在室内约会,免去天气的骚扰。</detail> </zhishu> <zhishu> <name>逛街指数</name> <value>较不宜</value> <detail>风大有降水,逛街注意带雨具。</detail> </zhishu> <zhishu> <name>晾晒指数</name> <value>不宜</value> <detail>降水可能会淋湿衣物,请选择在室内晾晒。</detail> </zhishu> <zhishu> <name>雨伞指数</name> <value>带伞</value> <detail>有降水,短时间出行不必带伞。</detail> </zhishu> </zhishus> </resp>
这次是xml数据,
包含实时天气,日出日落,空气质量(某些城市可能不存在),天气预警(预警时存在),昨日天气(分白天黑夜),未来七天天气(分白天黑夜),天气指数
我想现在要求再高,也能满足你的需求了吧!!!!!
下面贴接口!!!!
通过城市id获得天气数据,xml文件数据,
当错误时会有<error>节点
http://wthrcdn.etouch.cn/WeatherApi?city=北京
通过城市名字获得天气数据,xml文件数据
ok,教程贴完了!!!希望朋友们多多支持!!!本菜鸟在此谢过了!!!!