试图从Yahoo!获取RSS财政部根据安德鲁和Dylan瓦拉德答案在Parse RSS with jQuery但收到的错误:获取Yahoo!使用JQuery和Google API的财务RSS错误
data.responseData是空
成功() 数据= {对象= responseDetails“饲料无法加载。”,responseStatus = 400,responseData = NULL}
载入来自浏览器的相同的URL或PHP卷曲返回OK RSS数据
网址:http://feeds.finance.yahoo.com/rss/2.0/headline?s= ^富时, URL编码:HTTP%3A%2F%2Ffeeds.finance.yahoo .COM%2Frss%2F2.0%2Fheadline%3FS%3D% 5EFTSE
从我的Mac上的本地虚拟主机(OS X 10.5.8,XAMPP 1.7.3)进行测试。我尝试了使用Google API的zRSSfeed插件,并收到了同样的错误:“Feed无法加载”。索引数据和图表预先
function getRSS(symbol, url, callback) {
$('#rss').html('http://feeds.finance.yahoo.com/rss/2.0/headline?s='+symbol+'<br />');
$('#rss').append(encodeURIComponent(url));
$.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
success:
function (data) {
callback(data.responseData.feed);
},
error:
function (jqXHR, textStatus, errorThrown) {
$('#rss').append('<span class="downVal">'+textStatus+'</span>');
$('#rss').append('<br />'+'<span class="downVal">'+errorThrown+'</span>');
}
});
}
function parseRSS(newsFeed) {
$('#rss').append(newsFeed);
}
jQuery(document).ready(function($) {
...
summary(symbol);
$('#chart').html('<img style="-webkit-user-select:none" src="http://chart.finance.yahoo.com/z?s='+symbol+'&t=3m&q=l&l=on&z=m&p=m20,m200,v&a=r14,m26-12-9">');
getRSS(symbol, 'http://feeds.finance.yahoo.com/rss/2.0/headline?s='+symbol, parseRSS);
...
感谢您的建议,它帮助我找到了问题。区域和语言url参数是必需的,但我认为它们是可选的,因为我对文档感到困惑:“那么您可以使用语言/区域本地化提要结果”。此外,你必须编码“^”字符,指出它是一个指数,而不是股票;我在我的代码中完成了,但在帖子中省略了该行。所以,正确的网址是:http://feeds.finance.yahoo.com/rss/2.0/headline?s=%5EFTSE®ion=US&lang=en-US – hsands 2011-12-30 01:47:15