• MSXML2.ServerXMLHTTP responseText 获取的内容不完整,解决方案


    今天无意发现一个问题, 有个别几个网页使用 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

  • 相关阅读:
    EXT性能优化(转载)
    xampp 下配置mail()函数发邮件
    从存储过程中返回结果 (转载)
    HDU1394 Minimum Inversion Number
    HDU4414 Finding crosses
    POJ1328 Radar Installation
    HDU3308 LCIS
    POJ2352 Stars
    POJ2513 Colored Sticks
    HDU4027 Can you answer these queries?
  • 原文地址:https://www.cnblogs.com/personnel/p/4747697.html
Copyright © 2020-2023  润新知