Eventually I want to be able to do the following:
- Parse a list of external RSS feeds
- Merge all the feeds together
- Randomise the order so all the items from all the feeds are mixed
- Print the list
For now I'm focusing on step 1, which I'm able to do successfully using YQL:
var site = 'http://www.comfyshoulderrest.com/scrape.php?id=1';
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + site + '"') + '&format=xml';
$.get(yql).done(function (rss)
{
$(rss).find("item").each(function ()
{
var $shop_name = $(this).find('shop_name').text();
var $product_url = $(this).find('product_url').text();
var $photo_url = $(this).find('photo_url').text();
var $html =
"<div class='item'>" +
"<a href='" + $product_url + "'>" +
"<div class='image'><img src='" + $photo_url + "' style='width: 100%;'></div>" +
"</a>" +
"<div class='text'>" +
"<ul class='list-inline'>" +
"<li><span class='price text-warning'><strong>£7.00</strong></span> <span class='text-muted'><strike>£14.00</strike></span></li>" +
"<li class='text-muted'><strong>" + $shop_name + "</strong></li>" +
"</ul>" +
"</div>" +
"</div>"
$('#container').append($html).masonry('appended', $html);
});
});
However, the result is slow (which can't be the case given that this is a replacement for Chrome's new tab page) and I don't want to rely on an external API that no doubt has a usage limit.
I don't want to use a plugin because I need a solution that's malleable enough to be able to perform steps 2, 3 and 4.
I've tried using $.get
but that throws Single Origin Policy issues at me. I've heard JSONp is the best way to get around that.
Any suggestions at what the best approach is?