Search code examples
asp-classicserverxmlhttp

asp ServerXMLHTTP doesnt get all of source code


set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.Open "GET", "http://www.yapi.com.tr/Haberler/e_61034.html", false
objXmlHttp.Send
response.write  objXmlHttp.ResponseText

This code doesnt give me to all of source code. Responsetext is until "Yapı Dergisi, 284" but orjinal page is until "/body /html". Why this happend to me?

Orjinal page - http://www.yapi.com.tr/Haberler/e_61034.html

My code - http://www.mekanturu.com/1.asp


Solution

  • In the original page, there appears to be a null byte at the end of the main article (after the "284"). It appears that ResponseText is treating that null byte as the end of the response string. I was able to get the full article by using the following:

    <%
    Response.CharSet = 65001
    Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
    set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    objXmlHttp.Open "GET", "http://www.yapi.com.tr/Haberler/e_61034.html", false
    objXmlHttp.Send
    Response.BinaryWrite  objXmlHttp.ResponseBody
    %>
    

    Note that I set the response character set to UTF-8 which matches the original page.