从网页上摘录



有些网页上有不断更新的信息,如:股票信息,天气预报等。可以运用下面介绍的ASP方法把这些信息从网页上摘录下来为我所用。

 

<%function getHTTPPage(url)dim httpset http=createobject("MSXML2.XMLHTTP")Http.open "GET/Http.send()if Http.readystate <> 4 thenexit functionend ifgetHTTPPage=Http.responseBodygetHTTPPage=bytes2BSTR(Http.responseBody)set http=nothingend function

Function bytes2BSTR(vIn)dim strReturndim i,ThisCharCode,NextCharCodestrReturn = ""For i = 1 To LenB(vIn)ThisCharCode = AscB(MidB(vIn,i,1))If ThisCharCode < &H80 ThenstrReturn = strReturn & Chr(ThisCharCode)ElseNextCharCode = AscB(MidB(vIn,i+1,1))strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))i = i + 1End IfNextbytes2BSTR = strReturnEnd Function

wstr = getHTTPPage("http://127.0.0.1/test/test.asp")************************************下面的代码是对收到的网页字串进行处理************************************strStart="TEMP<br><br>"strEnd="</body>"wstr=mid(wstr,instr(wstr,strStart)+len(strStart))wstr=mid(wstr,1,instr(wstr,strEnd)-1)

wstr=replace(wstr,"ASP/

Response.Write wstr%>

posted @ 2006-04-07 10:28  spring3  阅读(134)  评论(0编辑  收藏  举报