使用多个<link />(jquery)解析RSS提要

时间:2015-09-30 20:47:49

标签: javascript jquery rss

我正在使用jQuery解析并将三个RSS提要输出到三个不同的容器div中。前两个Feed工作正常,但我无法获得第三个Feed中的链接,根本找不到href。请参阅小提琴http://jsfiddle.net/a68myvm2/1/

我认为它与第三个Feed包含每个项目的多个链接标记有关。我尝试在网上搜索解决方案但没有成功。

HTML

<div id="content_1"></div>
<div id="content_2"></div>
<div id="content_3"></div>

JS

    $(function () {
function GetFeeds(){
var urls = ['http://www.gosugamers.net/counterstrike/news/rss', 'http://www.hltv.org/news.rss.php', 'http://feeds.thescoreesports.com/csgo.rss'];
urls.forEach(function(Query){
$.ajax({
  type: "GET",
  url: 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q='+encodeURIComponent(Query),
  dataType: 'json',
  error: function () {
  alert('Unable to load feed, Incorrect path or invalid feed');
  },
  success: function(xml) {

var Content=parseInt(urls.indexOf(Query))+1;
    $("#content_"+Content).html('');  
    $.each(xml.responseData.feed.entries, function(idx, value){
    $("#content_"+Content).append('<a class="news-item" href="' + value.link + '" title="' + value.title +'" target="_blank"><p>' + value.publishedDate + '</p><h3>' + value.title + '</h3></a><hr>');    
  });
  }
});
});
}
//Call GetFeeds every 5 seconds.
setInterval(GetFeeds,5000);
//Page is ready, get feeds.
GetFeeds();
});

部分有问题的Feed(http://feeds.thescoreesports.com/csgo.rss

    <item>
          <guid isPermaLink="false">4117</guid>
          <title>ScrunK joins Team Coast as Coach</title>
          <link>http://www.thescoreesports.com/news/4117</link>
          <pubDate>Wed, 30 Sep 2015 18:02:45 +0000</pubDate>
          <dc:creator/>
          <media:content url="https://dqrt72khb0whk.cloudfront.net/uploads/image/file/2729/w1080xh810_coast.jpg?ts=1432916713">
            <media:credit>Team Coast</media:credit>
          </media:content>
          <content:encoded>
            <![CDATA[<p>Team Coast have brought in German CS:GO professional, Robin &quot;<strong>ScrunK</strong>&quot; R&ouml;pke, to take the reigns as the team&#39;s coach, the organization announced Wednesday. </p><figure><blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">We would like to officially welcome <a href="https://twitter.com/CSTScrunK">@CSTScrunK</a> as our new CS:GO coach! Please show your support and give him a follow!!</p>&mdash; Team Coast (@TeamCoastGaming) <a href="https://twitter.com/TeamCoastGaming/status/649268154590470144">September 30, 2015</a></blockquote>
        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></figure><p>&quot;I would like to thank Team Coast and the players for giving me this opportunity to throw my EU knowledge and style into the NA scene,&quot; said ScrunK in his <a href="http://www.hltv.org/news/16051-scrunk-joins-team-coast-as-coach">statement to HLTV.org</a>. &quot;I am excited to see where this route in my career leads me and where I can help this team go.&quot;</p><p>Team Coast are currently competing in the North American divisions of both CEVO-P Season 8 and ESL ESEA Pro League Season 2. They currently sit at sixth in the CEVO-P division with a 2-4-3 record and third in the ESL ESEA Pro League with a record of 3-4.</p><p><em>Paul Park is a wr​iter for theScore eSports. <a target="_blank" href="https://twitter.com/phjpark">You can follow him on Twitter</a>.</em></p><p><small><em>Copyright &copy; 2015 Score Media Ventures Inc. All rights reserved. Certain content reproduced under license.</em></small></p>]]>
          </content:encoded>
          <link rel="related" type="text/html" href="http://www.thescoreesports.com/news/4070" title="Dead Pixels CS:GO part ways with FARIS and YOUNS"/>
          <link rel="related" type="text/html" href="http://www.thescoreesports.com/news/4115" title="G2.Kinguin add jkaem to roster"/>
          <link rel="related" type="text/html" href="http://www.thescoreesports.com/news/4102" title="ESL ESEA Pro League Hot Match of week 3"/>
          <link rel="related" type="text/html" href="http://www.thescoreesports.com/news/4061" title="HIGHLIGHT: azr shuts down Winterfox"/>
          <link rel="related" type="text/html" href="http://www.thescoreesports.com/news/4063" title="DreamHack Stockholm Group B Roundup: Down and out"/>
 </item>

0 个答案:

没有答案