您的位置:首页 > 理论基础 > 计算机网络

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

2014-11-03 23:13 661 查看
参考:ASP四个小技巧,抓取网页:GetBody,字节转字符BytesToBstr,正则表达式测试方法,生成静态页
Function GetBody(weburl)
'创建对象
Dim ObjXMLHTTP
Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")
'请求文件,以异步形式
ObjXMLHTTP.Open "GET",weburl,False
'此信息必须在send前一个设置否则将出错"msxml3.dll error '80004005' Unspecified error"
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
'如果下面的方法在调用时使用()则会出现以下错误,如果非要使用()则需要使用call来调用方法
'参考:/article/5121006.html
“ Microsoft VBScript compilation error '800a0414'Cannotuse parentheses when calling a Sub”
'xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
ObjXMLHTTP.send
While ObjXMLHTTP.readyState <> 4
ObjXMLHTTP.waitForResponse 1000
Wend
'得到结果
GetBody=ObjXMLHTTP.responseBody
'释放对象
Set ObjXMLHTTP=Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
[/code]来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: