Asp 将MSXML2.serverXMLHTTP返回的responseBody 内容转换成支持中文编码
参考:ASP四个小技巧,抓取网页:GetBody,字节转字符BytesToBstr,正则表达式测试方法,生成静态页
Function GetBody(weburl)'创建对象Dim ObjXMLHTTPSet 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来调用方法“ Microsoft VBScript compilation error '800a0414'Cannotuse parentheses when calling a Sub”'xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")ObjXMLHTTP.sendWhile ObjXMLHTTP.readyState <> 4ObjXMLHTTP.waitForResponse 1000Wend'得到结果GetBody=ObjXMLHTTP.responseBody'释放对象Set ObjXMLHTTP=NothingEnd FunctionFunction BytesToBstr(body,Cset)dim objstreamset objstream = Server.CreateObject("adodb.stream")objstream.Type = 1objstream.Mode =3objstream.Openobjstream.Write bodyobjstream.Position = 0objstream.Type = 2objstream.Charset = CsetBytesToBstr = objstream.ReadTextobjstream.Closeset objstream = nothingEnd Function
浙公网安备 33010602011771号