XMLHTTP抓取数据时乱码问题解决

类别:Asp 点击:0 评论:0 推荐:

CSDN原帖:
http://community.csdn.net/Expert/topic/3316/3316086.xml?temp=.2790033


内码问题.用这段代码的吧,我已经改得很精简了.
'使用XMLHTTP抓取地址并进次内容处理
Function GetBody(Url)
  Dim objXML
        On Error Resume Next
        Set objXML = CreateObject("Microsoft.XMLHTTP")
        With objXML
        .Open "Get", Url, False, "", ""
        .Send
        GetBody = .ResponseBody
        End With
        GetBody=BytesToBstr(GetBody,"GB2312")
        Set objXML = Nothing
End Function
'使用Adodb.Stream处理二进制数据
Function BytesToBstr(strBody,CodeBase)
        dim objStream
        set objStream = Server.CreateObject("Adodb.Stream")
        objStream.Type = 1
        objStream.Mode =3
        objStream.Open
        objStream.Write strBody
        objStream.Position = 0
        objStream.Type = 2
        objStream.Charset = CodeBase
        BytesToBstr = objStream.ReadText
        objStream.Close
        set objStream = nothing
End Function

本文地址:http://com.8s8s.com/it/it8789.htm