如题...高手讲讲实现的 基本流程吧.很多代码没有注释,看起来特别累.小弟诚心学习!

解决方案 »

  1.   

    xmlhttp对象获取数据 转换编码 完工!
      

  2.   

        '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
      

  3.   

    msgbox BytesToBstr(GetBody("http://www.baidu.com/"),"gb2312")