雅虎天气网络服务

发布于 2024-10-11 15:11:45 字数 215 浏览 3 评论 0原文

我正在尝试找到一种使用雅虎查询语言通过雅虎天气获取一些天气信息的方法。

由于我住在法国的尼斯市,以下查询返回错误:

select * from weather.forecast where location='Nice'

我已经协调了纬度和经度,那么如何将它们提供给 YQL 以返回天气信息?这项服务是全球范围内的还是仅适用于美国?

I'm trying to find a way to get some weather information with Yahoo Weather using Yahoo Query Language.

As I'm living in France, in a city called Nice, the following query returns an error:

select * from weather.forecast where location='Nice'

I have the latitude and longitude coordinated, so how can I give them to YQL to return the weather info? Is this service worldwide or just for the US?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我要还你自由 2024-10-18 15:11:45

您应该使用另一个 YQL 数据表。我已经尝试过这个查询,它工作正常:

SELECT * FROM weather.bylocation WHERE location='Nice' AND unit="c"

这是 YQL 控制台

我已添加 unit=" c" 来获取摄氏温度,假设您想要这样。如果没有,请使用“f”。

在内部,weather.bylocation 表使用以下两件事:

  1. 查找该位置的“地球上哪里”标识符 (woeid),
  2. 然后查找该位置的天气ID。

请参阅下表的内部结构:

    <execute><![CDATA[
      default xml namespace ='http://where.yahooapis.com/v1/schema.rng'; 
      var x = y.query('select woeid from geo.places(1) where text="'+location+'"');
      var s = x.results;
      var woeid = s..woeid;
      var weather = y.rest('http://weather.yahooapis.com/forecastrss?w='+woeid+'&u='+unit).get().response;
      response.object = <weather>{weather}</weather>;
    ]]></execute>

关于您关于协调纬度和经度的使用的第二个问题:
我不知道你是否可以使用它们,但也许你现在甚至不再需要它了,对吧?

也很好读:

http://developer.yahoo.com/weather/

http://developer.yahoo.com/geo/geoplanet/guide/concepts.html

You should use another YQL datatable instead. I have tried this query and it works fine:

SELECT * FROM weather.bylocation WHERE location='Nice' AND unit="c"

This is the YQL console

I have added unit="c" to get it it Celsius, assuming that you want that. If not, use "f".

Internally the weather.bylocation table is using the following two things:

  1. Lookup of the 'where on earth identifier (woeid) for the location,
  2. and then lookup of the weather for this id.

See the internals of that table below:

    <execute><![CDATA[
      default xml namespace ='http://where.yahooapis.com/v1/schema.rng'; 
      var x = y.query('select woeid from geo.places(1) where text="'+location+'"');
      var s = x.results;
      var woeid = s..woeid;
      var weather = y.rest('http://weather.yahooapis.com/forecastrss?w='+woeid+'&u='+unit).get().response;
      response.object = <weather>{weather}</weather>;
    ]]></execute>

Regarding your 2nd question about usage of latitude and longitude coordinated:
I don't know if you can use them but maybe you don't even need this anymore now, right?

Also good read:

http://developer.yahoo.com/weather/

http://developer.yahoo.com/geo/geoplanet/guide/concepts.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文