问题
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