为什么执行有时行有时不行。。。
Function GetBody(URL) on error resume next
Set Retrieval = Server.CreateObject("MSXML2.XMLHTTP")
'Set Retrieval = Server.CreateObject("MSXML2.ServerXMLHTTP")
'Set Retrieval = Server.CreateObject("MsXml2.XmlHttp5.0") 'MsXml2.XmlHttp5.0
With Retrieval
.Open "Get",URL,False,"",""
.setTimeouts 10000,10000,10000,30000
.SetRequestHeader "Referer","AL_HTML" '将HTTP头中来源页变为AL_HTML
.Send
if .readystate<>4 then
Response.Write("链接 config1.asp --- getbody 失败!")
' Response.End()
end if
GetBody = .ResponseBody '获得未经解码的二进制数据
End With
'response.write 1111111111
'response.end
GetBody = BytesToBstr222(GetBody,"GB2312") '调用解码函数
'response.write GetBody
'response.end
Set Retrieval = Nothing
End Function
Function BytesToBstr222(Body,Cset)
set Objstream = Server.CreateObject("Adodb.Stream")
Objstream.Type = 1
Objstream.Mode =3
Objstream.Open
Objstream.Write body
Objstream.Position = 0
Objstream.Type = 2
Objstream.Charset = Cset
BytesToBstr222 = Objstream.ReadText
Objstream.Close
set Objstream = nothing
End Function
有时没有返回参数啊,奇怪了。就是有时可以得到返回值,有时不能。网络没问题,相应的网站可以的。
排除网站,我不是用域名来而是用IP:例如;192.168.1.211:8080来连接的。