会新闻小偷程序的进来,高分请教!
klark 2004-02-09 10:58:48 新闻来源页面:
http://www.jxmu.edu.cn/news/news.jsp
我的偷新闻程序如下:
<%
on error resume next
Server.ScriptTimeOut=120 '设定操作超时的时间(因为程序运行速度慢啊)
url = "http://www.jxmu.edu.cn/news/news.jsp" '新闻来源的页面
wstr = getHTTPPage(url) '取得页面内容
if err.number=0 then '如果获取成功
start=newstring(wstr,"<td width=""74%"" height=""25"" align=""left"" background=""images/line-3.gif"">") '要获取的内容在网页中的开始位置(通过唯一的标志寻找)
over=newstring(wstr,"</font> </li></td>") '要获取的内容在网页中结束位置(通过唯一的标志寻找)
wstr=mid(wstr,start,over-start) '获取想要的内容
wstr=replace(wstr,"<a href=""news1.jsp","<a href=""http://www.jxmu.edu.cn/news/news1.jsp")'替换掉你不想要的内容
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
%>
结果却只显示了一条新闻,(效果见http://www.yd.jxmu.edu.cn/newyd/yd/homepage/1.asp)
我想添加一个循环控制,但是不知道怎么加,哪个高手知道怎么改我的程序?