json - 返回雅虎!使用YQL的摄氏温度天气API数据

标签 json yahoo yql

我正在尝试获得Yahoo!摄氏温度的天气API。

我在请求中添加了&u=c,但是它仍以华氏温度返回数据。

这是我正在使用的URL:


http://query.yahooapis.com/v1/public/yql?q=select%20item%20from%20weather.forecast%20where%20location=%22LEXX0003%22&format=json&u=c


以及响应:

{"query":{"count":1,"created":"2014-01-13T13:06:43Z","lang":"en-US","results":{"channel":{"item":{"title":"Conditions for Beirut, LE at 1:59 pm EET","lat":"33.82","long":"35.48","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Beirut__LE/*http://weather.yahoo.com/forecast/LEXX0003_f.html","pubDate":"Mon, 13 Jan 2014 1:59 pm EET","condition":{"code":"30","date":"Mon, 13 Jan 2014 1:59 pm EET","temp":"64","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/30.gif\"/><br />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 64 F<BR />\n<BR /><b>Forecast:</b><BR />\nMon - Partly Cloudy. High: 64 Low: 55<br />\nTue - Cloudy. High: 66 Low: 56<br />\nWed - Mostly Sunny. High: 68 Low: 58<br />\nThu - Sunny. High: 70 Low: 60<br />\nFri - Scattered Showers. High: 65 Low: 57<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Beirut__LE/*http://weather.yahoo.com/forecast/LEXX0003_f.html\">Full Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\" >The Weather Channel</a>)<br/>\n","forecast":[{"code":"30","date":"13 Jan 2014","day":"Mon","high":"64","low":"55","text":"Partly Cloudy"},{"code":"26","date":"14 Jan 2014","day":"Tue","high":"66","low":"56","text":"Cloudy"},{"code":"34","date":"15 Jan 2014","day":"Wed","high":"68","low":"58","text":"Mostly Sunny"},{"code":"32","date":"16 Jan 2014","day":"Thu","high":"70","low":"60","text":"Sunny"},{"code":"39","date":"17 Jan 2014","day":"Fri","high":"65","low":"57","text":"Scattered Showers"}],"guid":{"isPermaLink":"false","content":"LEXX0003_2014_01_17_7_00_EET"}}}}}}`


有任何想法吗?

最佳答案

迟到总比不到好...

var locationQuery = escape("select item from weather.forecast where woeid in (select woeid from geo.places where text='GB-LND') and u='c'"),
    locationUrl = "http://query.yahooapis.com/v1/public/yql?q=" + locationQuery + "&format=json&callback=?";


如果将其分解,则更容易阅读。您非常接近,只需要u = c作为查询的一部分,而不是网址的末尾。

关于json - 返回雅虎!使用YQL的摄氏温度天气API数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21092164/

相关文章:

javascript - 如何通过jQuery ajax发送Json数据和文本框数据

r - 无法使用 R 中的 Quantmod 从雅虎财经下载数据

java - 从公司名称获取股票代码

html - 子 div 背景颜色 HTML 雅虎电子邮件有问题

javascript - 使用 JavaScript 从另一个网站获取 div 的内容

javascript - AngularJS,Ng-repeat 更改/更改 Json 数组的顺序

sql - PostgreSQL - 使用大小写将带引号的字符串转换为不同的字符串?

c# - "Pass through".NET Core 3.1 中的 Controller 操作(获取并返回 JSON)

python - 为什么使用Python-YQL模块会将sys.path[0]更改为sys.path[1]?

yql - 是否可以在 YQL 中对字段进行别名或重命名?