ASP function code
Copy Code code 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
%>
The code in PHP
Copy Code code as follows:
<?php
$search = Array ("' <script[^>]*?>.*?</script> ' si",//Remove JavaScript
"' <style[^>]*?>.*?</style> ' si",//Remove CSS
"' <[/!] *? [^<>]*?> ' Si ',//Remove HTML tags
"' <!--[/!] *? [^<>]*?> ' Si ',//Remove comment mark
"' ([RN]) [s]+ '],//remove white space characters
"' & (quot| #34); ' I ",//Replace 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 (161),
Chr (162),
Chr (163),
Chr (169),
"Chr (\1)");
$document for strings to be processed if the source is a file can $document = file_get_contents (' http://www.sina.com.cn ');
$out = Preg_replace ($search, $replace, $document);
Echo $out;
?>
Save as get.php can be.