简体   繁体   English

从RSS获取Img标签描述

[英]Getting Img Tag from RSS Description

I currently have a couple of RSS feeds which hide their images within the pesky description tag. 我目前有一些RSS feed,它们将它们的图像隐藏在讨厌的description标签中。

I'm trying to get only the image src from the description, but I seem to be failing with every solution on here. 我试图从描述中仅获取图像src,但此处的每种解决方案似乎都失败了。

<description><![CDATA[Duration: 604 sec<br>URL: http://www.test.com/videos/998879/surf.mpeg<br><img src="http://test.test.com/320x240/461/1055458.jpg"><br><iframe src="http://test.com/embed/998879" frameborder=0 width=650 height=518 scrolling=no></iframe>]]></description>

As you can see it's a bit stuck in there! 如您所见,它有点卡在其中!

function echo_url($string) {
preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $string, $match);
return $match[0][0];
}

Currently using this function to try and retrieve the image but no luck! 当前正在使用此功能尝试检索图像,但是没有运气!

Any help would be brilliant! 任何帮助将是辉煌的!

$description = '<description><![CDATA[Duration: 604 sec<br>URL: http://www.test.com/videos/998879/surf.mpeg<br><img src="http://test.test.com/320x240/461/1055458.jpg"><br><iframe src="http://test.com/embed/998879" frameborder=0 width=650 height=518 scrolling=no></iframe>]]></description>';
$html = str_get_html($description);
echo $html->find('img', 0)->src;

http://simplehtmldom.sourceforge.net/ http://simplehtmldom.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM