如何在简单的html dom中从html标签中获取desire-intertext


How to get desire innertext from html tag in simple html dom

我有一些文本,其中有代码。我想从链接中获取最后一条文本。这是一个的例子

Some text<a href="http://beezfeed.cu.ma">Beezfeed.cu.ma</a><br>
another text<a href="http://google.com">Google.com</a><br>

我想从上面的代码中获得Google.com的文本。我尝试过使用Simple html dom。不管怎样,这是我的代码

   <?PHP
require_once('simple_html_dom.php');
$html = new simple_html_dom();
function tags($ddd){
$bbb=$ddd->find('a',1);
    foreach($bbb as $bs){
    echo $bs->innertext;
    }
}
$html = str_get_html('Some text<a href="http://beezfeed.cu.ma">Beezfeed.cu.ma</a><br>
another text<a href="http://google.com">Google.com</a><br>');
echo tags($html);
?> 

我想了解一下Google.com如何获取。请帮助我

我强烈建议您使用一些外部库来解析HTML。您需要的任何HTML。根据您今天或将来的需要。一些非常好的工具在这些stackoverflow帖子中被命名。

我个人使用simplehtmldom.sourceforge.net已经很久了,效果非常好。