天气API接口

豆瓣测试接口 点击打开链接

https://api.douban.com/v2/book/search?q=%E5%93%88%E5%88%A9%E6%B3%A2%E7%89%B9&count=20

新浪天气预报API

点击打开天气API

http://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.com

http://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: 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>

 

<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.cn

http://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=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天气图标

 
posted @ 2013-05-27 16:35  RattanyiXu  阅读(5144)  评论(5编辑  收藏  举报