REM 獲取對(duì)應(yīng)網(wǎng)址響應(yīng)的HTML Function BytesToBstr(body) 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 = "UTF-8"
'轉(zhuǎn)換原來默認(rèn)的UTF-8編碼轉(zhuǎn)換成GB2312編碼,否則直接用 'XMLHTTP調(diào)用有中文字符的網(wǎng)頁得到的將是亂碼 BytesToBstr = objstream.ReadText objstream.Close set objstream = nothing End Function
REM 使用正則表達(dá)式,抓取之內(nèi)標(biāo)記的內(nèi)容 Function GetBody(ConStr,StartStr,OverStr,IncluL,IncluR) If ConStr="$False$" or ConStr="" or IsNull(ConStr)=True Or StartStr="" or IsNull(StartStr)=True Or OverStr="" or IsNull(OverStr)=True Then GetBody="$False$" Exit Function End If Dim ConStrTemp Dim Start,Over ConStrTemp=Lcase(ConStr) StartStr=Lcase(StartStr) OverStr=Lcase(OverStr) Start = InStrB(1, ConStrTemp, StartStr, vbBinaryCompare) If Start<=0 then GetBody="$False$" Exit Function Else If IncluL=False Then Start=Start+LenB(StartStr) End If End If Over=InStrB(Start,ConStrTemp,OverStr,vbBinaryCompare) If Over<=0 Or Over<=Start then GetBody="$False$" Exit Function Else If IncluR=True Then Over=Over+LenB(OverStr) End If End If GetBody=MidB(ConStr,Start,Over-Start) End Function
REM 過濾a超鏈接 Function RegRemoveHref(HTMLstr) Set ra = New RegExp ra.IgnoreCase = True ra.Global = True ra.Pattern = "<a[^>]+>(.+?)<//a>"
RegRemoveHref = Replace(ra.replace(HTMLstr,"$1"),"href=""http://www.927953.com""","") END Function %>