如何从API获取Yahoo Weather Backgrounds?
我有一个天气小部件,我需要动态背景。 雅虎有天气API,但我无法找到与天气类型相关的背景图片。 https://weather.yahoo.com/这可能吗?
var url = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D%2248907%22&format=json' $.getJSON(url, function (data) { console.log(data) })
API不提供任何图像,但您可以使用大量数据来提供图像。 例如,使用以下属性
condition":{"code":"34", ... // here you can bind an image to the code
然后你有一个风对象
wind":{ "chill":"55", // thermometer? "direction":"0", // use an image or a canvas to draw an arrow dynamically "speed":"0" }, ...
和一个氛围对象
"atmosphere":{ "humidity":"51", // some drops? "pressure":"30.4", // textual.. "rising":"2", "visibility":"10" // textual.. }, ...
等等。 正如您所看到的,有很多方法可以说明这些数据,但这完全取决于您如何做到这一点。
对不起,但没有API。 但您可以通过查看浏览器开发人员工具上的网络活动来访问其背景。
最好的解决方案是使用您自己的图像构建自己的Api,
这是背景url的示例: