在PHP简单HTML DOM解析器中动态排除内容 [英] Dynamically Exclude Content In PHP Simple HTML DOM Parser

查看:95
本文介绍了在PHP简单HTML DOM解析器中动态排除内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个基于PHP的应用程序,它将使用 PHP简单HTML DOM解析器。

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

我想从内容中动态排除两个HTML标记之间的某些文本。

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

如果源内容的代码为:

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

我想删除所有由< span class = s> 到第一个< b> HTML标记,因此输出为:

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...

这应该使用 foreach 循环,其想法是将所有过滤的文本存储在变量中,例如 $ ftext ,然后必须应用一些简单的PHP,例如:

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?

推荐答案

最好使用Arc90 HTML内容提取程序的可读性

better if you use readability by Arc90 HTML content extractor

这篇关于在PHP简单HTML DOM解析器中动态排除内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆