求助大神这是什么歌2,天气栏的城市WOEID怎么查

14641人阅读
公共资源(3)
Demo(11)
ASP.NET(105)
雅虎天气API调用:
1.调用方法:/forecastrss?w=2502265&u=c,绿色字体为城市代号,u=c表示取摄氏度。
2.如何获取城市代码:(以广州为例)&
& & 参数:output:输出数据格式,可以是xml或json,默认为xml;
& & & & & & & &command:要查询的城市名称
& & 可能会出现多个项,像这样:
&m q=&广& gprid=&iKCy1nr2SFGqEwa.Ugf2eA& c=&广& n=&10&&
&s k=&Guangzhou& d=&pt:iso=CN&woeid=2161838&lon=113.268&lat=23.1074&s=Guangdong&c=China&pn=广州市&/&
&s k=&Wuxue& d=&pt:iso=CN&woeid=2163907&lon=115.553&lat=29.8505&s=Hubei&c=China&/&
&s k=&Guangyuan& d=&pt:iso=CN&woeid=2157635&lon=105.818&lat=32.443&s=Sichuan&c=China&pn=广元&/&
&s k=&Guangshui& d=&pt:iso=CN&woeid=2163891&lon=113.99&lat=31.6134&s=Hubei&c=China&pn=广水镇&/&
&s k=&Guangxi& d=&s:iso=CN&woeid=&lon=108.267&lat=23.8597&s=Guangxi&c=China&pn=广西省&/&
&s k=&Guangdong& d=&s:iso=CN&woeid=&lon=113.419&lat=22.8588&s=Guangdong&c=China&pn=广东省&/&
&s k=&Guanghan& d=&t:iso=CN&woeid=2158448&lon=104.276&lat=30.9825&s=Sichuan&c=China&pn=广汉市&/&
&s k=&Sihui& d=&t:iso=CN&woeid=2161893&lon=112.685&lat=23.3427&s=Guangdong&c=China&/&
&s k=&Guang'an& d=&t:iso=CN&woeid=2157942&lon=106.636&lat=30.4765&s=Sichuan&c=China&pn=广安&/&
&s k=&Guangning& d=&t:iso=CN&woeid=2148035&lon=121.787&lat=41.5939&s=Liaoning&c=China&/&
prd08.gossip.search. compressed/chunked Mon Nov 18 10:06:32 UTC 2013
--&& & 如果是匹配的“广州”关键字,则就只有广州市的code数据了。
& &这里的woeid即是 城市代码
3.国内城市代码整理:下载Demo程序,将要查询的地区,写入文件bin\Debug\Data\cities.txt 即可(一行一个)
& &国内标准城市地区可以以参考:)
4.雅虎天气API结果解析:
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1555805次
积分:16932
积分:16932
排名:第417名
原创:387篇
转载:118篇
译文:21篇
评论:223条
(1)(2)(3)(3)(1)(4)(3)(6)(2)(2)(3)(8)(2)(7)(7)(2)(3)(2)(4)(3)(3)(8)(2)(3)(2)(5)(1)(3)(12)(6)(4)(11)(6)(1)(3)(3)(5)(3)(3)(8)(13)(23)(8)(6)(5)(15)(6)(4)(1)(6)(22)(6)(10)(2)(5)(12)(5)(12)(3)(5)(3)(2)(16)(7)(7)(4)(1)(5)(6)(7)(7)(4)(3)(10)(14)(7)(1)(2)(6)(18)(2)(27)(35)(1)(2)当前城市:厦门
厦门周边地区今天天气
全国天气预报地图
请点击省份名称进入查询
国际天气预报
二十四节气
热门城市天气预报
热门天气资讯
热门省市景点天气
热门天气常识
广告区域结束 -->查询时base_url:
/v1/public/yql?q= , 公共查询接口,有限制查询次数
/v1/yql?q= , 注册后获取ApkId,有限制查询次数但是已经足够使用了,10万次/天
第一步,手机端定位用户的位置(根据IP查询,或者。。。。),得到用户所在城市名称,或者城市名称的拼音,或者经纬度
第二步,根据用户所在城市的中文、英文、经纬度,获取woeid:
1,这里text键值可以用 中文、英文、经纬度。如
1): select * from geo.placefinder where text=&Guangzhou&
2): select * from geo.placefinder where text=&北京&
3): select * from geo.placefinder where text=&39..3404132&&and gflags = &R&
2,使用如下url查询城市的woeid:三种方法均可使用
/v1/public/yql?q=select * from geo.placefinder where text=&39..3404132&&and gflags = &R&&format=json
/v1/public/yql?q=select * from geo.placefinder where text=&北京&&format=json
/v1/public/yql?q=select * from geo.placefinder where text=&Guangzhou&&format=json
注意使用经纬度获取woeid时一直取不到,后来才知道时缺少一个参数 fglags参数。,必须加&and gflags = &R&这一串才行
返回的xml格式的数据:
&query xmlns:yahoo=&/v1/base.rng& yahoo:count=&1& yahoo:created=&T03:28:29Z& yahoo:lang=&en-US&&
&quality&40&/quality&
&latitude&23.12911&/latitude&
&longitude&113.26336&/longitude&
&offsetlat&23.12911&/offsetlat&
&offsetlon&113.26336&/offsetlon&
&radius&17700&/radius&
&line2&Guangzhou&/line2&
&line3&Guangdong&/line3&
&line4&People's Republic of China&/line4&
&xstreet/&
&unittype/&
&neighborhood/&
&city&Guangzhou&/city&
&state&Guangdong&/state&
&country&People's Republic of China&/country&
&countrycode&CN&/countrycode&
&statecode&44&/statecode&
&countycode/&
&woeid&2161838&/woeid& ,这个就是需要的woeid
&woetype&7&/woetype&
&/results&
&!-- &total: 11 &--&
第三步,根据上面返回的结果中得到woeid,查询天气数据:
1):把第一步获取的woeid放到下面的查询语句中:
select * from weather.forecast where woeid=2502265 and u=&c&
2):最后使用如下url即可得到天气数据:
/v1/public/yql?q=select * from weather.forecast where woeid=2502265 and u=&c&&format=json
返回的xml格式的数据:
&query xmlns:yahoo=&/v1/base.rng& yahoo:count=&1& yahoo:created=&T03:24:54Z& yahoo:lang=&en-US&&
&title&Yahoo! Weather - Sunnyvale, CA&/title&
http://us./dailynews/rss/weather/Sunnyvale__CA/*/forecast/USCA1116_c.html
&description&Yahoo! Weather for Sunnyvale, CA&/description&
&language&en-us&/language&
&lastBuildDate&Wed, 27 May
pm PDT&/lastBuildDate&
&ttl&60&/ttl&
&yweather:location xmlns:yweather=&http://xml./ns/rss/1.0& city=&Sunnyvale& country=&United States& region=&CA&/&
&yweather:units xmlns:yweather=&http://xml./ns/rss/1.0& distance=&km& pressure=&mb& speed=&km/h& temperature=&C&/&
&yweather:wind xmlns:yweather=&http://xml./ns/rss/1.0& chill=&15& direction=&350& speed=&19.31&/&
&yweather:atmosphere xmlns:yweather=&http://xml./ns/rss/1.0& humidity=&78& pressure=&1016.7& rising=&1& visibility=&16.09&/&
&yweather:astronomy xmlns:yweather=&http://xml./ns/rss/1.0& sunrise=&5:50 am& sunset=&8:19 pm&/&
&title&Yahoo! Weather&/title&
&width&142&/width&
&height&18&/height&
&link&&/link&
/a/i/brand/purplelogo//uh/us/news-wea.gif
&title&Conditions for Sunnyvale, CA at 7:55 pm PDT&/title&
&geo:lat xmlns:geo=&http://www.w3.org/2003/01/geo/wgs84_pos#&&37.37&/geo:lat&
&geo:long xmlns:geo=&http://www.w3.org/2003/01/geo/wgs84_pos#&&-122.04&/geo:long&
http://us./dailynews/rss/weather/Sunnyvale__CA/*/forecast/USCA1116_c.html
&pubDate&Wed, 27 May
pm PDT&/pubDate&
&yweather:condition xmlns:yweather=&http://xml./ns/rss/1.0& code=&34& date=&Wed, 27 May
pm PDT& temp=&15& text=&Fair&/&
&description&
&img src=&/a/i/us/we/52/34.gif&/&&br /& &b&Current Conditions:&/b&&br /& Fair, 15 C&BR /& &BR /&&b&Forecast:&/b&&BR /& Wed - Partly Cloudy. High: 21 Low: 12&br /& Thu - AM Clouds/PM Sun. High: 23 Low: 12&br /& Fri - AM Clouds/PM Sun. High:
24 Low: 13&br /& Sat - AM Clouds/PM Sun. High: 24 Low: 13&br /& Sun - AM Clouds/PM Sun. High: 22 Low: 14&br /& &br /& &a href=&http://us./dailynews/rss/weather/Sunnyvale__CA/*/forecast/USCA1116_c.html&&Full Forecast at Yahoo!
Weather&/a&&BR/&&BR/& (provided by &a href=&& &The Weather Channel&/a&)&br/&
&/description&
&yweather:forecast xmlns:yweather=&http://xml./ns/rss/1.0& code=&29& date=&27 May 2015& day=&Wed& high=&21& low=&12& text=&Partly Cloudy&/&
&yweather:forecast xmlns:yweather=&http://xml./ns/rss/1.0& code=&30& date=&28 May 2015& day=&Thu& high=&23& low=&12& text=&AM Clouds/PM Sun&/&
&yweather:forecast xmlns:yweather=&http://xml./ns/rss/1.0& code=&30& date=&29 May 2015& day=&Fri& high=&24& low=&13& text=&AM Clouds/PM Sun&/&
&yweather:forecast xmlns:yweather=&http://xml./ns/rss/1.0& code=&30& date=&30 May 2015& day=&Sat& high=&24& low=&13& text=&AM Clouds/PM Sun&/&
&yweather:forecast xmlns:yweather=&http://xml./ns/rss/1.0& code=&30& date=&31 May 2015& day=&Sun& high=&22& low=&14& text=&AM Clouds/PM Sun&/&
&guid isPermaLink=&false&&USCA_31_7_00_PDT&/guid&
&/channel&
&/results&
&!-- &total: 22 &--&
url后面的参数为设置返回数据类型,json或xml
这样就能拿到以摄氏度返回的天气了。
这里注意一点,天气的返回值里面有一个code,那个代表的是各种天气类型,暴风雨啊龙卷风啊冰雹啊之类的。
code与其对应天气状态:
1 tropical storm
2 hurricane
3 severe thunderstorms
4 thunderstorms
5 mixed rain and snow
6 mixed rain and sleet
7 mixed snow and sleet
8 freezing drizzle
10 freezing rain
11 showers
12 showers
13 snow flurries
14 light snow showers
15 blowing snow
23 blustery
27 mostly cloudy (night)
28 mostly cloudy (day)
29 partly cloudy (night)
30 partly cloudy (day)
31 clear (night)
33 fair (night)
34 fair (day)
35 mixed rain and hail
37 isolated thunderstorms
38 scattered thunderstorms
39 scattered thunderstorms
40 scattered showers
41 heavy snow
42 scattered snow showers
43 heavy snow
44 partly cloudy
45 thundershowers
46 snow showers
47 isolated thundershowers
3200 not available
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:7125次
排名:千里之外
原创:19篇
(1)(3)(3)(2)(2)(9)}

我要回帖

更多关于 求助大神这是什么歌2 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信