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

80酷酷网    80kuku.com

  xml|解决|数据|问题内码问题.用这段代码的吧,我已经改得很精简了.
'使用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



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: