MSXML2.ServerXMLHTTP responseText 获取的内容不完整,解决方案
2015-08-21 13:57
549 查看
今天无意发现一个问题, 有个别几个网页使用 MSXML2.ServerXMLHTTP 获取网页源代码的时候,.responseText 总是返回一部分内容,无法获取完整的内容。
经过搜索,找到解决方案: 使用 .responseBody (参考: http://blog.links.cn/asp/aspxmlhttp.html)
不过从参考的文章上看,他的问题与我不完全一样,我测试的时候,只需将 responseText 替换成 responseBody,问题就解决了。
参考文章中还提到 adodb.stream的一个BUG,需要将 chr(0) 替换成 ""
'httpGet = xmlhttp.responseText
httpGet = replace(BytesToBstr(xmlhttp.responseBody, "utf-8"), chr(0), "")
'字节根据指定编码转换成字符
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
经过搜索,找到解决方案: 使用 .responseBody (参考: http://blog.links.cn/asp/aspxmlhttp.html)
不过从参考的文章上看,他的问题与我不完全一样,我测试的时候,只需将 responseText 替换成 responseBody,问题就解决了。
参考文章中还提到 adodb.stream的一个BUG,需要将 chr(0) 替换成 ""
'httpGet = xmlhttp.responseText
httpGet = replace(BytesToBstr(xmlhttp.responseBody, "utf-8"), chr(0), "")
'字节根据指定编码转换成字符
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
相关文章推荐
- centos 挂载iscsi 连接网络存储 vnxe
- 网络打洞(P2P软件穿透内网进行通信) 原理
- HTML5之SVG详解(一) 时间 2012-12-21 19:49:00 博客园-原创精华区 原文 http://www.cnblogs.com/hupeng/archive/2012/12/2
- ConnectEx成功后设置SO_UPDATE_CONNECT_CONTEXT
- 用YourAPP开发网络状态提醒应用
- TCP/IP-概述
- TCP网络编程(Python)
- 问题:HttpWebRequest request post 传参; 结果:好用的C# HttpWebRequest用Post同时提交参数和文件的封装类
- Http请求
- struts2 java.io.FileNotFoundException: http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd
- VirtualBox 四种网络连接方式
- TCP状态转移图学习总结
- http 协议之安全--------https
- 让浏览器不再显示 https 页面中的 http 请求警报
- 404、500、502等HTTP状态码介绍
- 细说HTTP
- http协议中的get与post方法区别分析
- 网络socket编程指南
- 解决PHP curl https时error 77(Problem with reading the SSL CA cert (path? access rights?))
- WebSocket与TCP、Http的关系