How to copy web pages in ASP?

11 replies
I have just done some research on PHP and learned about several ways
how one can get content of a web page in PHP. I have also read one ASP
tutorial on w3schools, but I couldn 't find there any web-page copying
command or a function. Does anybody know?
#asp #copy #pages #web
  • Profile picture of the author codeswarrior
    Hello,

    Do you mean file operation in Asp. To do file operation in asp you requested to learn FileSystemObject.

    Thanks
    {{ DiscussionBoard.errors[301340].message }}
  • Profile picture of the author Sleaklight
    Save the following code in a file with the file extyension ending in .asp and place the link of the website page you want to copy. I use this code all the time since I integrate php coding results into asp pages since you can't run php in asp

    Code:
     
    <%
    set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    objHttp.open "GET", "LINK TO THE WEBSITE BEING COPIED", false
    objHttp.Send
    Response.Write objHTTP.ResponseText
    Set objHTTP = Nothing
    %>
    {{ DiscussionBoard.errors[337388].message }}
    • Will i be able to run this code on a remote asp-supported server?
      {{ DiscussionBoard.errors[340800].message }}
      • I just tried it on one free asp-supporting host and it works!!! It does display the page of the link that I have pasted there! But I am not sure where the html code of that page is. Does this script output the html code into some variable? Could I use also some file creating script in asp so that a file with html code of the copied page would be automatically created?
        {{ DiscussionBoard.errors[341782].message }}
    • Originally Posted by Sleaklight View Post

      Save the following code in a file with the file extension ending in .asp and place the link of the website page you want to copy. I use this code all the time since I integrate php coding results into asp pages since you can't run php in asp

      Code:
       
      <%
      set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
      objHttp.open "GET", "LINK TO THE WEBSITE BEING COPIED", false
      objHttp.Send
      Response.Write objHTTP.ResponseText
      Set objHTTP = Nothing
      %>
      As I said, this code works - it does open the requested web page -
      but I still can't copy it. How can I copy that page (its HTML code)?
      In which variable is it stored? Is it "obj HTTP.Response Text"?

      I guess there are three ways here:

      1) to copy the html code into a file on the server;
      2) to copy it into a database on the server;
      3) or have it e-mailed to my mailbox without saving it on the server;

      Since I am running this script on a free remote server, the first way
      seems to be unlikely - on the free asp-severs that I have used they
      are afraid of viruses and, therefore, don't allow to use scripting
      objects like creating files & folders, so I can't automatically create a
      file and save HTML code into that file.

      So I am working on the other two ways at the moment, but I still
      need to know where (in which variable) this code is contained.
      {{ DiscussionBoard.errors[347728].message }}
  • Profile picture of the author Sleaklight
    I am not sure I understand what you are trying to do then. It should run anywhere, you just place the link of the page you want to copy in it and it'll do it.
    {{ DiscussionBoard.errors[340816].message }}
  • Profile picture of the author rwil02
    it stored? Is it "obj HTTP.ResponseText"?

    Yes. That is where the text returned by the requset is stored.
    You could also use "obj HTTP.ResponseXml" If you were certain that the page you were requested was valid XML.
    Signature

    Roger Willcocks
    L-Space Design
    Please vote to help me win a 3kW solar array

    {{ DiscussionBoard.errors[349316].message }}
    • Okay, I got it, thanks.

      So, now, how do I get this text out of that
      variable and copy it either into a text file on the server or
      into one of the fields of my database on the server?
      {{ DiscussionBoard.errors[349977].message }}
  • Profile picture of the author THowell
    YEAH! I learned something
    {{ DiscussionBoard.errors[370360].message }}

Trending Topics