我想知道如何从 RSS 和 Atom 订阅中提取图像,以便在容器中显示订阅的缩略图、标题、描述和链接。到目前为止,我的代码(如下所示)仅从某些订阅类型中获取图像,我想知道如何获取脚本遇到的每个图像。
if (feed_image_type == "description") {
item_img = $($(this).find('description').text()).find("img").attr("src");
} else if (feed_image_type == "encoded") {
item_img = $($(this).find('encoded').text()).find("img").attr("src");
} else if (feed_image_type == "thumbnail") {
item_img = $(this).find('thumbnail').attr('url');
} else {
item_img = $(this).find('enclosure').attr('url');
}
例如,我无法弄清楚如何从以下rss源代码片段中获取图像链接:
<description>
<![CDATA[
<img src="https://i.kinja-img.com/gawker-media/image/upload/s--E93LuLOd--/c_fit,fl_progressive,q_80,w_636/hd6cujrvf1d72sbxsbnr.jpg" /><p>With a surprise showing of skill and, at one point, a miracle, the bottom-ranked team in the European <em>League </em>Championship Series will not end the summer winless.<br></p><p><a href="http://compete.kotaku.com/european-league-team-finally-wins-its-first-series-of-t-1797363638">Read more...</a></p>
]]>
</description>
$(this).find('img').attr('src')
吗? - styfle