1. 程式人生 > >真正的中國天氣api介面xml,json(求加精) ...

真正的中國天氣api介面xml,json(求加精) ...

我只想說現在網上那幾個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資料,未來七天的天氣。。。全了!!!
包含實時氣溫,感冒指數,未來七天天氣(風力,風向,高低溫,時間),空氣質量指數(有的城市沒有),城市名稱

下面貼地址!!!!

本帖隱藏的內容

http://wthrcdn.etouch.cn/weather_mini?city=北京
通過城市名字獲得天氣資料,json資料
http://wthrcdn.etouch.cn/weather_mini?citykey=101010100
通過城市id獲得天氣資料,json資料



如果這還不夠!!!下面還有!!!!

<resp><br style="word-wrap: break-word;" />
<city>北京</city><br style="word-wrap: break-word;" />
<updatetime>16:10</updatetime><br style="word-wrap: break-word;" />
<wendu>23</wendu><br style="word-wrap: break-word;" />
<fengli>3級</fengli><br style="word-wrap: break-word;" />
<shidu>19%</shidu><br style="word-wrap: break-word;" />
<fengxiang>北風</fengxiang><br style="word-wrap: break-word;" />
<sunrise_1/><br style="word-wrap: break-word;" />
<sunset_1/><br style="word-wrap: break-word;" />
<sunrise_2/><br style="word-wrap: break-word;" />
<sunset_2/><br style="word-wrap: break-word;" />
<environment><br style="word-wrap: break-word;" />
<aqi>59</aqi><br style="word-wrap: break-word;" />
<pm25>30</pm25><br style="word-wrap: break-word;" />
<suggest>極少數敏感人群應減少戶外活動</suggest><br style="word-wrap: break-word;" />
<quality>良</quality><br style="word-wrap: break-word;" />
<MajorPollutants>顆粒物(PM10)</MajorPollutants><br style="word-wrap: break-word;" />
<o3>93</o3><br style="word-wrap: break-word;" />
<co>0</co><br style="word-wrap: break-word;" />
<pm10>67</pm10><br style="word-wrap: break-word;" />
<so2>8</so2><br style="word-wrap: break-word;" />
<no2>25</no2><br style="word-wrap: break-word;" />
<time>15:00:00</time><br style="word-wrap: break-word;" />
</environment><br style="word-wrap: break-word;" />
<alarm><br style="word-wrap: break-word;" />
<cityKey>10101</cityKey><br style="word-wrap: break-word;" />
<cityName><br style="word-wrap: break-word;" />
<![CDATA[ 北京市 ]]><br style="word-wrap: break-word;" />
</cityName><br style="word-wrap: break-word;" />
<alarmType><br style="word-wrap: break-word;" />
<![CDATA[ 大風 ]]><br style="word-wrap: break-word;" />
</alarmType><br style="word-wrap: break-word;" />
<alarmDegree><br style="word-wrap: break-word;" />
<![CDATA[ 藍色 ]]><br style="word-wrap: break-word;" />
</alarmDegree><br style="word-wrap: break-word;" />
<alarmText><br style="word-wrap: break-word;" />
<![CDATA[ 北京市氣象臺釋出大風藍色預警 ]]><br style="word-wrap: break-word;" />
</alarmText><br style="word-wrap: break-word;" />
<alarm_details><br style="word-wrap: break-word;" />
<![CDATA[ 預計,3日下午到夜間,本市大部分地區將出現6級以上大風,陣風7-8級,請注意防範。 ]]><br style="word-wrap: break-word;" />
</alarm_details><br style="word-wrap: break-word;" />
<standard><br style="word-wrap: break-word;" />
<![CDATA[<br style="word-wrap: break-word;" />
24小時內可能受大風影響,平均風力可達6級以上,或者陣風7級以上;或者已經受大風影響,平均風力為6~7級,或者陣風7~8級並可能持續。<br style="word-wrap: break-word;" />
]]><br style="word-wrap: break-word;" />
</standard><br style="word-wrap: break-word;" />
<suggest><br style="word-wrap: break-word;" />
<![CDATA[<br style="word-wrap: break-word;" />
1.政府及相關部門按照職責做好防大風工作;2.關好門窗,加固圍板、棚架、廣告牌等易被風吹動的搭建物,妥善安置易受大風影響的室外物品,遮蓋建築物資;3.相關水域水上作業和過往船舶採取積極的應對措施,如回港避風或者繞道航行等;4.行人注意儘量少騎自行車,颳風時不要在廣告牌、臨時搭建物等下面逗留;5.有關部門和單位注意森林、草原等防火。<br style="word-wrap: break-word;" />
]]><br style="word-wrap: break-word;" />
</suggest><br style="word-wrap: break-word;" />
<imgUrl><br style="word-wrap: break-word;" />
<![CDATA[<br style="word-wrap: break-word;" />
http://www.weather.com.cn/m2/i/about/alarmpic/0501.gif<br style="word-wrap: break-word;" />
]]><br style="word-wrap: break-word;" />
</imgUrl><br style="word-wrap: break-word;" />
<time>2014-05-03 12:51:14</time><br style="word-wrap: break-word;" />
</alarm><br style="word-wrap: break-word;" />
<yesterday><br style="word-wrap: break-word;" />
<date_1>2日星期五</date_1><br style="word-wrap: break-word;" />
<high_1>高溫 23℃</high_1><br style="word-wrap: break-word;" />
<low_1>低溫 12℃</low_1><br style="word-wrap: break-word;" />
<day_1><br style="word-wrap: break-word;" />
<type_1>晴</type_1><br style="word-wrap: break-word;" />
<fx_1>無持續風向</fx_1><br style="word-wrap: break-word;" />
<fl_1>微風</fl_1><br style="word-wrap: break-word;" />
</day_1><br style="word-wrap: break-word;" />
<night_1><br style="word-wrap: break-word;" />
<type_1>晴</type_1><br style="word-wrap: break-word;" />
<fx_1>無持續風向</fx_1><br style="word-wrap: break-word;" />
<fl_1>微風</fl_1><br style="word-wrap: break-word;" />
</night_1><br style="word-wrap: break-word;" />
</yesterday><br style="word-wrap: break-word;" />
<forecast><br style="word-wrap: break-word;" />
<weather><br style="word-wrap: break-word;" />
<date>3日星期六</date><br style="word-wrap: break-word;" />
<high>高溫 24℃</high><br style="word-wrap: break-word;" />
<low>低溫 11℃</low><br style="word-wrap: break-word;" />
<day><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>北風</fengxiang><br style="word-wrap: break-word;" />
<fengli>5-6級</fengli><br style="word-wrap: break-word;" />
</day><br style="word-wrap: break-word;" />
<night><br style="word-wrap: break-word;" />
<type>多雲</type><br style="word-wrap: break-word;" />
<fengxiang>北風</fengxiang><br style="word-wrap: break-word;" />
<fengli>5-6級</fengli><br style="word-wrap: break-word;" />
</night><br style="word-wrap: break-word;" />
</weather><br style="word-wrap: break-word;" />
<weather><br style="word-wrap: break-word;" />
<date>4日星期日</date><br style="word-wrap: break-word;" />
<high>高溫 19℃</high><br style="word-wrap: break-word;" />
<low>低溫 8℃</low><br style="word-wrap: break-word;" />
<day><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>北風</fengxiang><br style="word-wrap: break-word;" />
<fengli>4-5級</fengli><br style="word-wrap: break-word;" />
</day><br style="word-wrap: break-word;" />
<night><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</night><br style="word-wrap: break-word;" />
</weather><br style="word-wrap: break-word;" />
<weather><br style="word-wrap: break-word;" />
<date>5日星期一</date><br style="word-wrap: break-word;" />
<high>高溫 21℃</high><br style="word-wrap: break-word;" />
<low>低溫 9℃</low><br style="word-wrap: break-word;" />
<day><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</day><br style="word-wrap: break-word;" />
<night><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</night><br style="word-wrap: break-word;" />
</weather><br style="word-wrap: break-word;" />
<weather><br style="word-wrap: break-word;" />
<date>6日星期二</date><br style="word-wrap: break-word;" />
<high>高溫 21℃</high><br style="word-wrap: break-word;" />
<low>低溫 10℃</low><br style="word-wrap: break-word;" />
<day><br style="word-wrap: break-word;" />
<type>多雲</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</day><br style="word-wrap: break-word;" />
<night><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</night><br style="word-wrap: break-word;" />
</weather><br style="word-wrap: break-word;" />
<weather><br style="word-wrap: break-word;" />
<date>7日星期三</date><br style="word-wrap: break-word;" />
<high>高溫 24℃</high><br style="word-wrap: break-word;" />
<low>低溫 12℃</low><br style="word-wrap: break-word;" />
<day><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</day><br style="word-wrap: break-word;" />
<night><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</night><br style="word-wrap: break-word;" />
</weather><br style="word-wrap: break-word;" />
<weather><br style="word-wrap: break-word;" />
<date>8日星期四</date><br style="word-wrap: break-word;" />
<high>高溫 23℃</high><br style="word-wrap: break-word;" />
<low>低溫 11℃</low><br style="word-wrap: break-word;" />
<day><br style="word-wrap: break-word;" />
<type>晴</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</day><br style="word-wrap: break-word;" />
<night><br style="word-wrap: break-word;" />
<type>陰</type><br style="word-wrap: break-word;" />
<fengxiang>無持續風向</fengxiang><br style="word-wrap: break-word;" />
<fengli>微風</fengli><br style="word-wrap: break-word;" />
</night><br style="word-wrap: break-word;" />
</weather><br style="word-wrap: break-word;" />
</forecast><br style="word-wrap: break-word;" />
<zhishus><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>感冒指數</name><br style="word-wrap: break-word;" />
<value>較易發</value><br style="word-wrap: break-word;" />
<detail>風較大,較易發生感冒,注意防護。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>紫外線</name><br style="word-wrap: break-word;" />
<value>弱</value><br style="word-wrap: break-word;" />
<detail>輻射較弱,塗擦SPF12-15、PA+護膚品。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>穿衣指數</name><br style="word-wrap: break-word;" />
<value>較冷</value><br style="word-wrap: break-word;" />
<detail>建議著厚外套加毛衣等服裝。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>舒適度</name><br style="word-wrap: break-word;" />
<value>舒適</value><br style="word-wrap: break-word;" />
<detail>白天不冷不熱,風力不大。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>洗車指數</name><br style="word-wrap: break-word;" />
<value>不宜</value><br style="word-wrap: break-word;" />
<detail>有雨,雨水和泥水會弄髒愛車。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>旅遊指數</name><br style="word-wrap: break-word;" />
<value>一般</value><br style="word-wrap: break-word;" />
<detail>有降水,風稍大,外出注意防雷防風。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>運動指數</name><br style="word-wrap: break-word;" />
<value>較不宜</value><br style="word-wrap: break-word;" />
<detail>有降水,推薦您在室內進行休閒運動。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>晨練指數</name><br style="word-wrap: break-word;" />
<value>較不宜</value><br style="word-wrap: break-word;" />
<detail>室外鍛鍊請攜帶雨具。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>約會指數</name><br style="word-wrap: break-word;" />
<value>不適宜</value><br style="word-wrap: break-word;" />
<detail>建議在室內約會,免去天氣的騷擾。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>逛街指數</name><br style="word-wrap: break-word;" />
<value>較不宜</value><br style="word-wrap: break-word;" />
<detail>風大有降水,逛街注意帶雨具。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>晾晒指數</name><br style="word-wrap: break-word;" />
<value>不宜</value><br style="word-wrap: break-word;" />
<detail>降水可能會淋溼衣物,請選擇在室內晾晒。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
<zhishu><br style="word-wrap: break-word;" />
<name>雨傘指數</name><br style="word-wrap: break-word;" />
<value>帶傘</value><br style="word-wrap: break-word;" />
<detail>有降水,短時間出行不必帶傘。</detail><br style="word-wrap: break-word;" />
</zhishu><br style="word-wrap: break-word;" />
</zhishus><br style="word-wrap: break-word;" />
</resp>



這次是xml資料,
包含實時天氣,日出日落,空氣質量(某些城市可能不存在),天氣預警(預警時存在),昨日天氣(分白天黑夜),未來七天天氣(分白天黑夜),天氣指數


我想現在要求再高,也能滿足你的需求了吧!!!!!
下面貼介面!!!!


本帖隱藏的內容

http://wthrcdn.etouch.cn/WeatherApi?citykey=101010100
通過城市id獲得天氣資料,xml檔案資料,
當錯誤時會有<error>節點
http://wthrcdn.etouch.cn/WeatherApi?city=北京
通過城市名字獲得天氣資料,xml檔案資料








ok,教程貼完了!!!希望朋友們多多支援!!!本菜鳥在此謝過了!!!!