简体   繁体   English

在PHP简单HTML DOM解析器中动态排除内容

[英]Dynamically Exclude Content In PHP Simple HTML DOM Parser

I am making a PHP-based application which will fetch content from a site using the PHP Simple HTML DOM Parser . 我正在制作一个基于PHP的应用程序,它将使用PHP Simple HTML DOM Parser从站点获取内容。

I want to exclude some text between two HTML tags from the content dynamically. 我想从内容中动态排除两个HTML标记之间的某些文本。

If the source code of the content is: 如果内容的源代码是:

Some description or content ETC ABC <span class="s"> May 3  2009 <b> ABC Some Text </b> Some photo or video...

I want to remove all the text wrapped by <span class="s"> to the first <b> HTML tag, so the output will be: 我想将所有<span class="s">包裹的文本删除到第一个<b> HTML标记,因此输出为:

Some description or content ETC ABC <span class="s"><b> ABC Some Text </b> Some photo or video...

This should done using a foreach loop and, the idea is, to get all the filtered text in a variable like $ftext and then have to apply some simple PHP like: 这应该使用foreach循环完成,其思想是,将所有过滤的文本存储在$ftext这样的变量中,然后必须应用一些简单的PHP,例如:

foreach($html->find('how_to_tell_those_filtered_text_here') as $ftext)
$result = str_replace($ftext, '', $result);
$result = str_get_html($result);

So, what should be the solution, any idea? 那么,解决方案应该是什么?

如果使用Arc90 HTML内容提取器的可读性,效果会更好

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

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