network forecast desarrolladores code json api yahoo

json - desarrolladores - yahoo weather api forecast code



Regresar Yahoo! datos de la API meteorológica en Celsius, utilizando YQL (4)

Estoy tratando de obtener Yahoo! API meteorológica con temperaturas en grados Celsius.

He agregado &u=c en la solicitud, pero todavía está devolviendo datos en Fahrenheit.

Esta es la URL que estoy usando:

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

Y la respuesta:

{"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"}}}}}}`

algunas ideas ?


Mejor tarde que nunca...

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=?";

Es más fácil de leer si lo rompes. Usted es bastante cercano, solo necesitaba el u = c como parte de la consulta, no al final de la url.


Cada vez que tenía que llamar a una temperatura que quería en Celsius, solo usaba una función de conversión simple:

function FtoC(temp) {return Math.round((temp - 32) / (9 / 5));}

Por otra parte, quería cambiar entre Fahrenheit y Celsius. Simplemente llamando al elemento Celsius JSON de Yahoo es probablemente mejor si todo lo que quiere usar es Celsius.


Usé el yql

select item from weather.forecast where woeid=22724447 and u=''c''

y funcionó bien con los resultados en Celsius. Cambié el "LEXX0003" por el verdadero WOEID de esa zona y parece haber funcionado.


Puedes intentar esto:

Consulta YQL:

select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="jiangmen,cn") and u="c"

EndPoint:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22jiangmen%2Ccn%22)%20and%20u%3D%22c%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

Este trabajo cuando lo intento justo ahora