• home
  • forum
  • my
  • kt
  • download
  • Grab A HTML Page

    Author: 2007-06-30 19:09:00 From:

    There is a very cool way to download or grab a file using ServerXMLHTTP class. Using this object you could access and download a remote file out side of your website.

    In this example, we will try to access default page from gazatem.com. If  the status message is 200, we will display all content of this page.

    <html><head><title>How to Grab A HTML Page Within an ASP</title></head>
    <body>
        <%
        Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
        objXmlHttp.open "GET", "http://www.gazatem.com/", False
        objXmlHttp.send

            if objXmlHttp.status = 200 then
                ' Return header code must be equal to 200
                strHTML = objXmlHttp.responseText
                response.Write(Server.HTMLEncode(strHTML))
                else
                ' There is an erro
                response.Write("Error : " & objXmlHttp.statusText)
                end if
            Set objXmlHttp = Nothing
        %>

    </body></html>

    Happy Coding !

    discuss this topic to forum

    relation tutorial

    No relevant information

    New

    Hot