ASP Functions Code
Copy code The Code is as follows: <%
Function removehtml (STR)
Dim objregexp, match, strhtml
If isnull (STR) then
STR = ""
End if
Strhtml = Str
Strhtml = Replace (replace (strhtml, vblf, ""), vbcr, ""), vbcrlf ,"")
Set objregexp = new Regexp
Objregexp. ignorecase = true
Objregexp. Global = true
Objregexp. pattern = "<SCRIPT [^>] *?>. *? </SCRIPT>"
Strhtml = objregexp. Replace (strhtml ,"")
Objregexp. pattern = "<style [^>] *?>. *? </Style>"
Strhtml = objregexp. Replace (strhtml ,"")
Objregexp. pattern = "<. +?> "
Strhtml = objregexp. Replace (strhtml ,"")
Set objregexp = nothing
Removehtml = strhtml
End Function
%>
PHP Code copy Code the code is as follows: $ search = array ("' 'si ", // remove JavaScript
" ' 'si ", // remove CSS
" '<[/!] *? [^ <>] *?> 'Si ", // remove the HTML tag
" ' ] *?> 'Si ", // remove the annotation mark
" '([Rn]) [s] + '", // remove the blank character
"'& (quot | #34);' I", // Replace the HTML Entity
"'& (Amp | #38 ); 'I ",
"' & (LT | #60); 'I ",
"' & (GT | #62); 'I ",
"'& (nbsp | #160);' I",
"'& (iexcl | #161);' I ",
"'& (cent | #162);' I",
"'& (pound | #163);' I ",
"'& (copy | #169);' I",
"'(D +); 'E "); // run as PHP Code
$ Replace = array ("",
"",
"",
"",
"\ 1 ",
"\"",
"&",
"<",
"> ",
"",
CHR (1, 161 ),
CHR (1, 162 ),
CHR (1, 163 ),
CHR (1, 169 ),
"CHR (\ 1 )");
// $ Document is the string to be processed. if the source is a file, you Can $ document = file_get_contents ('HTTP: // www.sina.com.cn ');
$ Out = preg_replace ($ search, $ replace, $ document );
Echo $ out;
?>
Save it as get. php.