regEx.Pattern = "[\s]*网站简介[\w\W]*All rights reserved[\s]*"
str = regEx.Replace(str, "")
regEx.Pattern = "(^\s*)|(\s*$)"
str = regEx.Replace(str, "")
HTMLfilter = trim(str)
end function
function getFolderDir(fullDir)
'输入得到全路径,得到文件夹路径
s=LastOne(fullDir,"\")
getFolderDir = left(fullDir,len(fullDir)-len(s))
end function
Function LastOne(Str,splitStr)
'输入字符和分隔符,得到最后一部分
LastOne = right(Str,len(Str)-InStrRev(Str,splitStr))
End Function
sub seachFile(theFolder)
dim f,f1,st,fd,fd1,t
set f = fso.GetFolder(theFolder)
for each f1 in f.Files
if lcase(right(f1.name,4))=".htm" then
set st = fso.OpenTextFile(f1,1,1)
'全读
if not st.AtEndOfStream then
t=st.readAll
set st = fso.OpenTextFile(getName(f1.name),2,1)
t=HTMLfilter(t)
st.write t
end if
end if
next
set fd = fso.GetFolder(theFolder)
for each fd1 in fd.SubFolders
seachFile fd1
next
end sub
sub gogogo()
seachFile thisFileFolder
alert "处理完毕"
end sub
function getName(x)
dim Arr,a,newName
newName=x
Arr=array("/","\",":","*","?",chr(34),"|","<",">",chr(39))
for each a in Arr
newName=replace(newName,a,"")
next
getName=replace(newName,".htm",".txt")
end function
</script>
Function RegExp_Replace(patrn,str,replStr)
Dim regEx ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置是否区分大小写。
RegExp_Replace = regEx.Replace(str,replStr) ' 作替换。
End Function
Function GetBody(Url)
Dim objXML
On Error Resume Next
Set objXML = CreateObject("Microsoft.XMLHTTP")
With objXML
.Open "Get", Url, False, "", ""
.Send
GetBody = .ResponseBody
End With
GetBody=BytesToBstr(GetBody,"GB2312")
Set objXML = Nothing
End Function
'使用Adodb.Stream处理二进制数据
Function BytesToBstr(strBody,CodeBase)
dim objStream
set objStream = Server.CreateObject("Adodb.Stream")
objStream.Type = 1
objStream.Mode =3
objStream.Open
objStream.Write strBody
objStream.Position = 0
objStream.Type = 2
objStream.Charset = CodeBase
BytesToBstr = objStream.ReadText
objStream.Close
set objStream = nothing
End Function
%>
Function RegExp_Replace(patrn,str,replStr)
Dim regEx ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置是否区分大小写。
RegExp_Replace = regEx.Replace(str,replStr) ' 作替换。
End Function