您好,我正在使用该声明
SELECT * FROM rss WHERE url="http://xml.weather.yahoo.com/forecastrss/SPXX0239_c.xml"
我获得了 5 天的预测数据,其中包含日期、图标、温度和文本,这非常棒。不过,我想获取其他信息,例如风寒、日出/日落以及温度感觉。我在请求中看不到它们?
这是我的数据回调
window['wCallback_2'] = function(data) {
// Get todays weather forecast
var info = data.query.results.item.forecast[0];
var code = info.code;
$('#wData_current .wDate_d').append('<TD>' + info.date) + '</TD>';
$('#wData_current .wDay_d').append('<TD>' + info.day) + '</TD>';
$('#wData_current .wIcon_d').append('<TD> <img src="http://l.yimg.com/a/i/us/we/52/' + code + '.gif" width="80" height="80" title="' + info.text + '" /> </TD>');
$('#wData_current .wText_d').append('<TD>' + info.text + '</TD>');
$('#wData_current .wHigh').append('<TD>' + info.high + '°' + u + '</TD>');
$('#wData_current .wLow').append('<TD>' + info.low + '°' + u + '</TD>');
};
最佳答案
rss
表只提供 <item>
内的内容元素。由于 RSS 是普通的旧式 XML,因此 xml
可以使用表格来代替。
SELECT * FROM xml
WHERE url="http://xml.weather.yahoo.com/forecastrss/SPXX0239_c.xml"
AND itemPath="rss.channel.*"
会给你一个data
对象结构如下:
{
"query": {
…
"results": {
"title": "Yahoo! Weather - Lanzarote, SP",
…
"location": { … },
"units": { … },
"wind": {
"chill": "19",
"direction": "20",
"speed": "32.19"
},
"atmosphere": { … },
"astronomy": {
"sunrise": "7:29 am",
"sunset": "8:19 pm"
},
"image": { … },
"item": {
"title": "Conditions for Lanzarote, SP at 8:59 pm WEST",
"lat": "28.95",
"long": "-13.6",
"link": … ,
"pubDate": "Mon, 15 Apr 2013 8:59 pm WEST",
"condition": { … },
"description": … ,
"forecast": [ … ],
"guid": { … }
}
}
}
}
要访问日出时间,您可以使用 data.query.results.astronomy.sunrise
.
关于javascript - YQL 天气声明未显示某些物体,例如日出、日落和风寒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16018339/