函数:
function xxfseo_body($body){
$body = preg_replace('~<(?!img)(\w+)\s+[^>]*>~i','<$1>', $body);
$body = preg_replace("/<(iframe.*?)>(.*?)<(\/iframe.*?)>/si", "", $body);
$body = preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si", "", $body);
$body = preg_replace("/<(script.*?)>(.*?)<\/script>/si", "", $body);
$body = preg_replace("~<(|/)form([^>]*)>~i", "", $body);
$body = preg_replace("~<input([^>]*)>~i", "", $body);
$body = preg_replace("/<(textarea.*?)>(.*?)<\/textarea>/si", "", $body);
$body = preg_replace("/<(botton.*?)>(.*?)<\/botton>/si", "", $body);
$body = preg_replace("/<(select.*?)>(.*?)<\/select>/si", "", $body);
$body = preg_replace("~<(|/)div([^>]*)>~i", "", $body);
$body = preg_replace("~<(|/)span([^>]*)>~i", "", $body);
$body = preg_replace("~<(|/)font([^>]*)>~i", "", $body);
$body = preg_replace("~<(|/)a([^>]*)>~i", "", $body);
$body = preg_replace("~<style[^>]*>(.*?)</style>~iUs", "", $body);
$body = preg_replace("~<xml[^>]*>(.*?)</xml>~iUs", '', $body);
$body = preg_replace("~<(|/)b>~i", "", $body);
$body = preg_replace('~<!--(.*)-->~','', $body);
$body = preg_replace('~<!--\[if [^\]]+\]>(.*?)<!\[endif\]-->~iUs','', $body);
$body = preg_replace('~<(\w+)[^>]*>\s*</\\1>~Us', '', $body);
$body = preg_replace("~[\r\n]+~",'', $body);
$body = preg_replace("~>\s*~",'>', $body);
$body = str_replace('</object>','', $body);
return trim($body);
}
非常好用,适合采集后处理比较复杂的html
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容