Asp 将MSXML2.serverXMLHTTP返回的responseBody 内容转换成支持中文编码

参考:ASP四个小技巧,抓取网页:GetBody,字节转字符BytesToBstr,正则表达式测试方法,生成静态页
  1. Function GetBody(weburl)
  2. '创建对象
  3. Dim ObjXMLHTTP
  4. Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")
  5. '请求文件,以异步形式
  6. ObjXMLHTTP.Open "GET",weburl,False
  7. '此信息必须在send前一个设置否则将出错"msxml3.dll error '80004005' Unspecified error"
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    '如果下面的方法在调用时使用()则会出现以下错误,如果非要使用()则需要使用call来调用方法
    “ Microsoft VBScript compilation error '800a0414'Cannotuse parentheses when calling a Sub”
    'xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")

  8. ObjXMLHTTP.send
  9. While ObjXMLHTTP.readyState <> 4
  10. ObjXMLHTTP.waitForResponse 1000
  11. Wend
  12. '得到结果
  13. GetBody=ObjXMLHTTP.responseBody
  14. '释放对象
  15. Set ObjXMLHTTP=Nothing
  16. End Function
  17. Function BytesToBstr(body,Cset)
  18. dim objstream
  19. set objstream = Server.CreateObject("adodb.stream")
  20. objstream.Type = 1
  21. objstream.Mode =3
  22. objstream.Open
  23. objstream.Write body
  24. objstream.Position = 0
  25. objstream.Type = 2
  26. objstream.Charset = Cset
  27. BytesToBstr = objstream.ReadText
  28. objstream.Close
  29. set objstream = nothing
  30. End Function





原文地址:https://www.cnblogs.com/huangtailang/p/4072478.html