详细解释已经写的很清楚,就不用偶再费口舌了:)
<%
on error resume next
Server.ScriptTimeOut=120 '设定操作超时的时间(因为程序运行速度慢啊)
url = "http://product.zol.com.cn/soft/" '新闻来源的页面
wstr = getHTTPPage(url) '取得页面内容
if err.number=0 then '如果获取成功
start=newstring(wstr," <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0""><!-- t {{{ -->") '要获取的内容在网页中的开始位置(通过唯一的标志寻找)
over=newstring(wstr,"<!-- 第一表结束 }}} -->") '要获取的内容在网页中结束位置(通过唯一的标志寻找)
wstr=mid(wstr,start,over-start-61) '获取想要的内容
wstr=replace(wstr,"aaa","bbb") '替换掉你不想要的内容
end if
response.write wstr '输出
%>
这些照抄:
<%
function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
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 NewString(wstr,strng)
NewString=Instr(wstr,strng)
End Function
%>
此程序占用资源确实比较大,如果网站有速度要求的话要甚用。