读取指定网页某区域内链接内容

<% Function ArrayRegExp(patrn, strng, strStart, strEnd) strng = Replace(strng, vbcrlf, "") Dim regEx, regEx1, regEx2 Dim Ms, M, v, i Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = True regEx.Global = True Set Ms = regEx.Execute(strng) Set regEx1 = New RegExp regEx1.Pattern = strStart regEx1.IgnoreCase = True regEx1.Global = True Set regEx2 = New RegExp regEx2.Pattern = strEnd regEx2.IgnoreCase = True regEx2.Global = True Dim Str i = 0 For Each M in Ms v = M.Value v = regEx1.Replace(v, "") v = regEx2.Replace(v, "") if i = 0 Then Str = v else Str = Str & vbcrlf & v end if i = i + 1 Next ArrayRegExp = Split(Str, vbcrlf) End Function '读取文本文件 ' Dim objFSO,objCountFile,FiletempData ' Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ' Set objCountFile = objFSO.OpenTextFile(Server.MapPath("test.txt"),1,True) ' FSOFileRead = objCountFile.ReadAll ' objCountFile.Close ' Set objCountFile=Nothing ' Set objFSO = Nothing '读取网页 FSOFileRead = GetSource("http://www.pipizy.com/movie/161445.html","<STRONG> &nbsp;PIPI","zy.list.checkbox.chooseAll") FileContent = Replace(FSOFileRead, vbcrlf, "") Dim B B = ArrayRegExp("<a.*?>.*?<//a>", FileContent, "<a.*?>", "<//a>") For i = 0 to Ubound(B) Response.Write(B(i)&"<br/>") Next '''''''''''''''''''读取网页函数'''''''''''''''''''''''' Function bytes2BSTR(vIn) dim i strReturn = "" For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode < &H80 Then strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End If Next bytes2BSTR = strReturn End Function function GetSource(url,strX,strY) '取得url页面的数据. dim oXmlHttp,oStream set oXmlHttp = Server.CreateObject("Microsoft.XMLHTTP") oXmlHttp.open "GET",url,false oXmlHttp.send() GetSource = bytes2BSTR(oXmlHttp.responseBody) ' 测试读取的内容写入到文本 ' Set fso = Server.CreateObject("Scripting.FileSystemObject") ' Set fout = fso.CreateTextFile(server.mappath("GetUrl.txt")) ' fout.Write GetSource ' fout.close ' set fout=nothing ' set fso=nothing ' response.End() startX = inStr(GetSource,strX) startY = inStr(GetSource,strY) startX = startX+len(strX) softLen = startY - startX GetSource = Mid(GetSource,startX,softLen) end function %>

你可能感兴趣的:(function,测试,url,regex,each)