Update1:使用完整的源代码:
$html1 = '<div class="pubanunciomrec" style="background:#FFFFFF;"><script type="text/javascript"><!--
google_ad_slot = "9853257829";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>';
$doc = phpQuery::newDocument($html1);
$html1 = $doc->remove('script');
echo $html1;
Run Code Online (Sandbox Code Playgroud)
源代码就是上面这个.我还读到存在一个错误,http://code.google.com/p/phpquery/issues/detail?id = 150我不知道它是否已经解决.
有关如何从此HTML中删除< script >的任何线索?
最好的祝福,
嗨,
我需要使用PhpQuery从HTML文档中删除所有< script >标记.
我做了以下事情:
$doc = phpQuery::newDocument($html);
$html = $doc['script']->remove();
echo $html;
Run Code Online (Sandbox Code Playgroud)
它不会删除< script >标记和内容.使用PhpQuery可以做到这一点吗?
最好的祝福,
小智 10
这有效:
$html->find('script')->remove();
echo $html;
Run Code Online (Sandbox Code Playgroud)
这不起作用:
$html = $html->find('script')->remove();
echo $html;
Run Code Online (Sandbox Code Playgroud)
从文档中看起来你会这样做:
$doc->remove('script');
Run Code Online (Sandbox Code Playgroud)
http://code.google.com/p/phpquery/wiki/Manipulation#Removing
编辑:
看起来PHPQuery中存在一个错误,但这可以改为:
$doc->find('script')->remove();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6745 次 |
最近记录: |