Dynamically Exclude Content In PHP Simple HTML DOM Parser

大兔子大兔子 提交于 2019-12-12 18:52:57

问题


I am making a PHP-based application which will fetch content from a site using the PHP Simple HTML DOM Parser.

I want to exclude some text between two HTML tags from the content dynamically.

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:

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($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?


回答1:


better if you use readability by Arc90 HTML content extractor



来源:https://stackoverflow.com/questions/13177740/dynamically-exclude-content-in-php-simple-html-dom-parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!