<%
'以下程序有IDCGE免费建站分享提供
tstyle="GB2312" '页面编码格式
url="" '采集源码页面的网址
tstartStr="
" '采集的结束部分
tcuttype="2"
tStr=gethttppage(url,tstyle)
content=CFstrcut(tStr,tstartStr,tendStr,tcuttype)
content=ReplaceIFrameTag(content)
response write content
'==================================================
'函数名:GetHttpPage
'作 用:获取网页源码
'参 数:HttpUrl ------网页地址
'==================================================
Function GetHttpPage(HttpUrl,style)
If IsNull(HttpUrl)=True Or Len(HttpUrl)<18 Or HttpUrl="$False$" Then
GetHttpPage="$False$"
Exit Function
End If
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",HttpUrl,False
Http.Send()
If Http.Readystate<>4 then
Set Http=Nothing
GetHttpPage="$False$"
Exit function
End if
GetHTTPPage=bytesToBSTR(Http.responseBody,style)
Set Http=Nothing
If Err.number<>0 then
Err.Clear
End If
End Function
'==================================================
'函数名:BytesToBstr
'作 用:将获取的源码转换为中文
'参 数:Body ------要转换的变量
'参 数:Cset ------要转换的类型
'==================================================
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
'---------------------------------------------------------
'采集程序 ’截取字符串,1.包括起始和终止字符,2.不包括
Function CFstrcut(strcontent,startstr,endstr,cuttype)
Dim strhtml,s1,s2
strhtml = strcontent
on error resume next
select case cuttype
case 1
s1 = instr(strhtml,startstr)
s2 = instr(s1,strhtml,endstr)+len(endstr)
case 2
s1 = instr(strhtml,startstr)+len(startstr)
s2 = instr(s1,strhtml,endstr)
end select
if err then
strcute = "
没有找到需要的内容。
"
err.clear
exit function
else
CFstrcut = mid(strhtml,s1,s2-s1)
end if
end Function
'过滤 iframe:
Function ReplaceIFrameTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "(