'ServerXMLHTTP 获取函数 Function GetBody(Weburl) On Error Resume Next Dim xmlHttp 'Set xmlHttp=createobject("Msxml2.XMLHTTP.4.0") 'set xmlHttp=createobject("Microsoft.XMLHTTP") Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP") xmlHttp.setTimeouts 4000, 4000, 4000, 8000 xmlHttp.Open "GET", Weburl, False xmlHttp.send If xmlHttp.readystate = 4 Then 'if xmlHttp.status=200 then GetBody = xmlHttp.responsebody 'end if Else GetBody = "" End If Dim sError If Err.Number <> 0 Then sError = Err.Number Err.Clear Else sError = "" End If Set xmlHttp = Nothing End Function '远程获取网页编码格式转换 Function BytesToBstr(body, charset) '转换成需要的编码格式 Dim objstream Set objstream = CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode = 3 objstream.Open On Error Resume Next objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.charset = charset BytesToBstr = objstream.ReadText objstream.Close Set objstream = Nothing End Function
Function GetBody(Weburl)
On Error Resume Next
Dim xmlHttp
'Set xmlHttp=createobject("Msxml2.XMLHTTP.4.0")
'set xmlHttp=createobject("Microsoft.XMLHTTP")
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlHttp.setTimeouts 4000, 4000, 4000, 8000
xmlHttp.Open "GET", Weburl, False
xmlHttp.send
If xmlHttp.readystate = 4 Then
'if xmlHttp.status=200 then
GetBody = xmlHttp.responsebody
'end if
Else
GetBody = ""
End If
Dim sError
If Err.Number <> 0 Then
sError = Err.Number
Err.Clear
Else
sError = ""
End If
Set xmlHttp = Nothing
End Function
'远程获取网页编码格式转换
Function BytesToBstr(body, charset) '转换成需要的编码格式
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
On Error Resume Next
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.charset = charset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function