要获取body标签中的内容,我使用下面的代码。如何在没有javascript代码的情况下获得正文内容
$html = @file_get_contents($url);
$doc = new DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('body');
$body = $nodes->item(0)->nodeValue;
如何从$ body中删除js代码?任何JS代码,看起来像
<script> /*Some js code*/ </script>
已经问: http://stackoverflow.com/questions/7130867/remove-script-tag-from-html-content – nullexception