Sunday, March 7, 2010

YQL Basic JSON Yahoo News Feed

Just getting started with YQL and JSON Feeds, must say im impressed...

A quick script to pull the top stories from yahoo news in a JSON Feed

$.getJSON(
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Frss.news.yahoo.com%2Frss%2Ftopstories%22&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json&callback?",
function(data) {
$.each(data.query.results.item,
function(index, item) {
var myItem = $("

");
$("").html(item.title).attr("href", item.link).appendTo(myItem);
$("
").appendTo(myItem);
myItem.appendTo("#MYDIVID");
});
}
);

That's all it takes...

0 comments: