How to Grab A HTML Page Within an ASP

posted by Scudyen date: Thursday, May 22, 2008 category: ASP
  Featured Story | Printable View | Email It | Comments | Write Comment

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 !


Custom Search



Gazatem Technologies Active News Manager


page counter

Listed with 411asp.net
Listed with 4aspin.com
PHP, ASP, .NET, JSP Resources, Reviews