在中国气象局官网上看到这个有个专门的API,去看看吧http://smart.weather.com.cn/wzfw/smart/weatherapi.shtml
国外免费天气API (国外天气软件Solar使用接口) http://www.wunderground.com/weather/api天气API-----开源免费天气预报接口API以及全国所有地区代码!!(国家气象局提供) http://www.linuxidc.com/Linux/2014-03/97742.htm
新浪天气预报API点击打开天气APIhttp://php.weather.sina.com.cn/xml.php?city=%B1%B1%BE%A9&password=DJOYnieT8234jlsK&day=0
http://php.weather.sina.com.cn/xml.php?city=%B1%B1%BE%A9&password=DJOYnieT8234jlsK&day=0
其中,city后的城市转码。Password固定Day为0表示当天天气,1表示第二天的天气,2表示第三天的天气,以此类推,最大为4返回的XML为
说明: <Profiles>
<Weather>
<city>北京</city>
<status1>晴</status1>
<status2>晴</status2>
<figure1>qing</figure1>
<figure2>qing</figure2>
<direction1>无持续风向</direction1>
<direction2>无持续风向</direction2>
<power1>≤3</power1>
<power2>≤3</power2>
<temperature1>7</temperature1>
<temperature2>-5</temperature2>
<ssd>0</ssd>
<tgd1>7</tgd1>
<tgd2>7</tgd2>
<zwx>2</zwx>
<ktk>7</ktk>
<pollution>3</pollution>
<xcz></xcz>
<zho></zho>
<diy></diy>
<fas></fas>
<chy>6</chy>
<zho_shuoming>暂无</zho_shuoming>
<diy_shuoming>暂无</diy_shuoming>
<fas_shuoming>暂无</fas_shuoming>
<chy_shuoming>棉衣、冬大衣、皮夹克、内着衬衫或羊毛内衣、毛衣、外罩大衣</chy_shuoming>
<pollution_l>一般</pollution_l>
<zwx_l>弱</zwx_l>
<ssd_l>较凉</ssd_l>
<fas_l>暂无</fas_l>
<zho_l>暂无</zho_l>
<chy_l>薄冬衣</chy_l>
<ktk_l>建议开启(制热)</ktk_l>
<xcz_l>暂无</xcz_l>
<diy_l>暂无</diy_l>
<pollution_s>对空气污染物扩散无明显影响</pollution_s>
<zwx_s>紫外线弱</zwx_s>
<ssd_s>老年、幼儿、体弱者外出需要带上薄围巾、薄手套。</ssd_s>
<ktk_s>建议开启空调</ktk_s>
<xcz_s>暂无</xcz_s>
<gm>2</gm>
<gm_l>易发期</gm_l>
<gm_s>天气很凉,季节转换的气候,慎重增加衣服;较易引起感冒;</gm_s>
<yd>5</yd>
<yd_l>不适宜</yd_l>
<yd_s>虽然晴空万里,但是户外运动时会感到很凉;</yd_s>
<savedate_weather>2013-03-01</savedate_weather>
<savedate_life>2013-03-01</savedate_life>
<savedate_zhishu>2013-03-01</savedate_zhishu>
</Weather>
</Profiles>
| 标签中1表示白天,2表示夜间 | |
| <status>< figure><direction><power><temperature><ssd><ssd_l><ssd_s><tgd><zwx><zwx_l><zwx_s><ktk><ktk_l><ktk_s><pollution><pollution_l><pollution_s><xcz><xcz_l><xcz_s><chy><chy_l><chy_shuoming><gm><gm_l><gm_s><yd><yd_l><yd_s><zho><zho_l><zho_shuoming><diy><diy_l><diy_shuoming><fas><fas_l><fas_shuoming><savedate_weather><savedate_life><savedate_zhishu> | 天气情况中文天气情况拼音风向风级温度体感指数数值体感度指数体感度指数说明体感温度紫外线指数数值紫外线指数紫外线指数说明空调指数数值空调指数 空调指数说明污染指数数值污染物扩散条件污染指数说明洗车指数数值洗车指数洗车指数说明穿衣指数数值穿衣指数穿衣说明感冒指数数值感冒指数感冒指数说明运动指数数值运动指数运动指数说明 天气预报日期生活日期指数日期 |
www.weather.comhttp://xoap.weather.com/weather/local/CHXX0138?cc=*&unit=m&dayf=2&link=xoap&prod=xoap&par=1220552427&key=c168fcf83120f8ed CHXX0138 为武汉的天气代码Unit=m 温度以摄氏度显示;去掉该参数,温度以华氏度显示Dayf为0,1返回当天天气,其他数字为多天天气,最大可为5,返回当天及往后4天的天气预报Par为注册时返回的Partner ID: 1220552427Key为注册时返回的License Key: c168fcf83120f8ed 说明:
| <loc id="CHXX0138"><dnam>Wuhan, China</dnam><tm>11:37 AM</tm><lat>30.58</lat><lon>114.27</lon><sunr>6:49 AM</sunr><suns>5:26 PM</suns><zone>8</zone></loc> | 城市的天气代码城市,国家查询时间纬度经度日出时间日落时间 |
| <cc></cc> | 当前天气 |
| <lsup>11/16/10 10:00 AM Local Time</lsup><obst>Wuhan, CHINA</obst><tmp>48</tmp><flik>48</flik><t>Fog</t><icon>20</icon> | 更新时间 当前温度体感温度天气情况天气图标 |
| <bar><r>30.36</r><d>steady</d></bar> | |
| <wind><s>2</s><gust>N/A</gust><d>0</d><t>VAR</t></wind> | 风速2英里/小时 |
| <dayf></dayf> | 传入的dayf参数,查询几天就有几个child |
| <lsup>11/16/10 2:36 PM Local Time</lsup>- <day d="0" t="Tuesday" dt="Nov 16"><hi>N/A</hi><low>43</low><sunr>6:49 AM</sunr><suns>5:26 PM</suns>- <part p="d"><icon>44</icon><t>N/A</t>- <wind><s>N/A</s><gust>N/A</gust><d>N/A</d><t>N/A</t></wind><bt>N/A</bt><ppcp>10</ppcp><hmid>N/A</hmid></part>- <part p="n"><icon>33</icon><t>Mostly Clear</t>- <wind><s>5</s><gust>N/A</gust><d>131</d><t>SE</t></wind><bt>M Clear</bt><ppcp>10</ppcp><hmid>92</hmid></part></day> | 更新时间日期高温低温日出时间日落时间白天天气情况天气图标 风 风向 Chance of Precip:10% 夜间天气情况天气图标大部分地区晴朗无云风5英里/小时 东南风风向:东南风 Chance of Precip:10% |
www.weather.com.cnhttp://m.weather.com.cn/data/101200101.html 数据页面101200101 为武汉的城市代码由 http://61.4.185.48:81/g/ 得到本机访问的IP,根据此IP查询到城市ID,var ip="61.183.248.221";var id=101200101;if(typeof(id_callback)!="undefined"){id_callback();}再根据城市ID返回该城市天气信息http://m.weather.com.cn/m/pn12/weather.htm该地址为天气插件的代码各城市ID见 《中国天气网城市代码.txt》
yahoo天气预报http://xml.weather.yahoo.com/forecastrss?w=2163866&u=cw对应各个地方在yahoo数据库中的WOEID,如北京的WOEID是2151330;武汉为2163866;u 为温度的单位,c表示摄氏度;f表示华氏度 http://xml.weather.yahoo.com/forecastrss?p=CHXX0138&u=cp为城市天气代码,不推荐使用没有预报几天的参数(或未找到),返回的XML中含有当天和第二天的天气基本情况。 说明:
| <yweather:location city="Wuhan" region="" country="CH" /><yweather:units temperature="C" distance="km" pressure="mb" speed="km/h" /><yweather:wind chill="9" direction="0" speed="3.22" /><yweather:atmosphere humidity="100" visibility="1.59" pressure="1015.92" rising="0" /><yweather:astronomy sunrise="6:49 am" sunset="5:25 pm" /> | 位置:城市,国家单位:温度单位(摄氏),间距单位,气压单位,风速单位风:冷风级别9,风向,风速3.22大气情况:湿度,能见度,压强, 天文:日出6:49am,日落5:25pm |
| <title>Conditions for Wuhan, CH at 10:00 am CST</title><geo:lat>30.58</geo:lat><geo:long>114.27</geo:long><link></link><pubDate>Tue, 16 Nov 2010 10:00 am CST</pubDate><yweather:condition text="Fog" code="20" temp="9" date="Tue, 16 Nov 2010 10:00 am CST" /> | 纬度经度链接更新时间/查询时间天气情况:text天气情况(雾),code天气图标,temp温度9摄氏度,date日期 |
| <yweather:forecast day="Tue" date="16 Nov 2010" low="6" high="16" text="Mostly Sunny" code="34" /><yweather:forecast day="Wed" date="17 Nov 2010" low="8" high="19" text="Sunny" code="32" /> | 天气预报:day星期,date日期,low低温,high高温,text天气情况,code天气图标 |