上面的代码有很多垃圾,这才是主要的:
<%
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
%>
/test/test.asp, line 46
__________________________________
怎么回事?
<body leftmargin="0" topmargin="0">
<%
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,"<img src=""images/mid.gif""","<img src=""http://product.zol.com.cn/soft/images/mid.gif""")
wstr=replace(wstr,"background=""images/bg.gif""","background=""http://product.zol.com.cn/soft/images/bg.gif""")
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
Function LeftNews(strng,NewsLength,NeedTime)
If NeedTime<>True then
Left_0=Instr(strng,"</a>")+3
TheRed=Instr(strng,"<font color=#ff0000>")
If TheRed>0 then
Left_1=Instr(strng,"<font color=#ff0000>")+20
Left_2=Instr(strng,"</font>")
If Left_1+NewsLength>=Left_2 then
LeftNews=Left(strng,Left_0)
Else
LeftNews=Left(strng,Left_1+NewsLength)&Points&"</font></a>"
End if
Else
Left_1=Instr(strng,"_blank>")+7
Left_2=Instr(strng,"</a>")
If Left_1+NewsLength>=Left_2 then
LeftNews=Left(strng,Left_0)
Else
LeftNews=Left(strng,Left_1+NewsLength)&Points&"</a>"
End if
End if
Else
LeftNews=strng
End if
End Function
Function NewString(wstr,strng)
NewString=Instr(wstr,strng)
End Function
Function NumDate()
NumDate=Year(Date())&AddZero(Month(Date()),2)&AddZero(Day(Date()),2)
End Function
Function FormatDate(theDate,n)
FormatDate=Year(theDate)&n&AddZero(Month(theDate),2)&n&AddZero(Day(theDate),2)
End Function
Function AddZero(m,n) '添加0
If Len(m)<n then
AddZero=string(n-Len(m),"0")&m
Else
AddZero=m
End if
End function
Function LL(strng)
LL=Left(strng,Instr(strng,"</a>")+3)
End function
Erase ArrayNewsImg
Erase ArrayNewsTitle
%>
http://expert.csdn.net/Expert/topic/2477/2477354.xml?temp=2.300662E-02
by manyou(他山之石)
怎么我的err.number是不等于0?
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,"<img src=""images/mid.gif""","<img src=""http://product.zol.com.cn/soft/images/mid.gif""")
wstr=replace(wstr,"background=""images/bg.gif""","background=""http://product.zol.com.cn/soft/images/bg.gif""")
end if
if err.number<>0 then
Response.Write "this is a error"
end if
______________________________________________________________________
输出的是:
this is a error
我了上面的关键函数写的!:(
url也肯定是能访问到!
搜索“httpxml”,关键函数:
function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Msxml2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then exit function
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