Retrieve the content of a remote file on the fly
Techniques
This section makes it possible to gather a whole of techniques or scripts which have the originality to manage to solve a difficulty with the least effort or which are particularly effective...The grayed entries relate to the future headings which will supplement soon this toolbox.
Techniques / Retrieve the content of a remote file on the fly using XMLHTTP
- How to retrieve the content of a remote file on the fly using XMLHTTP Object :
This tutorial is intented to learn you how it is possible to retrieve the content of a remote webpage on the fly with ASP. Something that can be very usefull in order to parse and search for information that could be shared with others or in order to send the content of a webpage via mail!
We going to use the XMLHTTP Microsoft object in order to call for the remote webpage . This object is included in the XML Dom component (it can be downloaded from the Microsoft website if you haven't it installed yet).
This object is generally used in order to retrieve remote XML file but it could also be used in order to retrieve a classic HTML page as you going to do.
In the following example you can change the variable thisURL to specify the url of the webpage yoy want to retrieve. The response of the remote server will be save into the ResponsePage variabe.
<% ' Url of the webpage we want to retrieve thisURL = "http://dypso.free.fr/index.php" ' Creation of the xmlHTTP object Set GetConnection = CreateObject("Microsoft.XMLHTTP") ' Connection to the URL GetConnection.Open "get", thisURL, False GetConnection.Send ' ResponsePage now have the response of ' the remote web server ResponsePage = GetConnection.responseText ' We write out now ' the content of the ResponsePage var Response.write (ResponsePage) Set GetConnection = Nothing %>
A question ? Use the forum !.