豆瓣测试接口
新浪天气预报API
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.com
CHXX0138 为武汉的天气代码
Unit=m 温度以摄氏度显示;去掉该参数,温度以华氏度显示
Dayf为0,1返回当天天气,其他数字为多天天气,最大可为5,返回当天及往后4天的天气预报
Par为注册时返回的Partner ID: 1220552427
Key为注册时返回的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> |
www.weather.com.cn
数据页面
101200101 为武汉的城市代码
由 得到本机访问的IP,根据此IP查询到城市ID,
var ip="61.183.248.221";var id=101200101;if(typeof(id_callback)!="undefined"){id_callback();}
再根据城市ID返回该城市天气信息
该地址为天气插件的代码
各城市ID见
yahoo天气预报
http://xml.weather.yahoo.com/forecastrss?w=2163866&u=c
w对应各个地方在yahoo数据库中的WOEID,如北京的WOEID是2151330;武汉为2163866;
u 为温度的单位,c表示摄氏度;f表示华氏度
http://xml.weather.yahoo.com/forecastrss?p=CHXX0138&u=c
p为城市天气代码,不推荐使用
没有预报几天的参数(或未找到),返回的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天气图标 |