Trying to get RSS from Yahoo! Finance based on answers from Andrew and Dylan Valade in Parse RSS with jQuery but receiving an error:
data.responseData is null
success() data = Object { responseDetails="Feed could not be loaded.", responseStatus=400, responseData=null}
Loading the same URL from the browser or PHP cURL returns the RSS data ok
url: http://feeds.finance.yahoo.com/rss/2.0/headline?s=^FTSE, url encode: http%3A%2F%2Ffeeds.finance.yahoo.com%2Frss%2F2.0%2Fheadline%3Fs%3D%5EFTSE
Testing from local vhost on my Mac (OS X 10.5.8, XAMPP 1.7.3). I tried zRSSfeed plugin wich also use Google API, and received the same error: "Feed could not be loaded". Index data and chart are working fine
Thanks in advance
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);
...
The first thing to point out is that the feed is returning a 400 code - so according to W3C recommendations, you shouldn't repeat the call.
10.4.1 400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
When I open the url:
http://feeds.finance.yahoo.com/rss/2.0/headline?s=^FTSE
I get a 404 error, so perhaps the search isn't always valid or is rate limited?
If you're convinced that the call is OK, then there is probably a problem with the line that calls the feed:
$('#rss').html('http://feeds.finance.yahoo.com/rss/2.0/headline?s='+symbol+'<br />'
So strip it back, alert out the symbol variable to make sure it is what you want, add lines like the following for some rudimentary debugging:
alert (symbol);
var feedUrl = 'http://feeds.finance.yahoo.com/rss/2.0/headline?s='+symbol;
alert (feedUrl);
... and finally check if appending the <br /> is actually breaking the feed url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With