Return Yahoo! weather API data in Celsius, using YQL

前端 未结 3 761
长情又很酷
长情又很酷 2021-02-12 18:45

I\'m trying to get Yahoo! weather API with temperatures in Celsius.

I\'ve added &u=c in the request, but it\'s still returning data in Fahrenheit.

3条回答
  •  北海茫月
    2021-02-12 19:14

    Better late than never...

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

    It's easier to read if you break it up. You we're pretty close, just needed the u=c as part of the query, not at the end of the url.

提交回复
热议问题