2

Eventually I want to be able to do the following:

  1. Parse a list of external RSS feeds
  2. Merge all the feeds together
  3. Randomise the order so all the items from all the feeds are mixed
  4. 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>&pound;7.00</strong></span> <span class='text-muted'><strike>&pound;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?

Sebastian
  • 3,548
  • 18
  • 60
  • 95
  • Possible duplicate of http://stackoverflow.com/questions/226663/parse-rss-with-jquery – Blazemonger Mar 26 '14 at 13:44
  • Unless I've missed one, all of those solutions either use a plugin or and API which are unsuitable for my means, so this is not a duplicate. – Sebastian Mar 26 '14 at 13:47
  • Have you tried to narrow down why your code is slow? Is it the AJAX request that's taking time, or the parsing? Your question as currently written is asking for "suggestions at what the best approach is," which is too broad for SO to answer. – Blazemonger Mar 26 '14 at 13:56
  • I'm told it's the request to Yahoo's server. Either way that's irrelevant because I'm after a solution that doesn't rely on an API. So my request is basically, how do I convert what I have into a standalone solution that doesn't use a plugin and doesn't use `$.get`. Is that a bit better? – Sebastian Mar 26 '14 at 14:04
  • 2
    http://stackoverflow.com/questions/10943544/how-to-parse-a-rss-feed-using-javascript – logic-unit Mar 26 '14 at 15:49

0 Answers0