In this tutorial, we will use Microsoft's XMLHTTP Request object's Web page remote address from our server. This object is contained in Microsoft's XML DOM component, which may be installed on your server.
The traditional Microsoft XMLHTTP object is to access remote XML files. In this basic tutorial, we will use it to get the text code from a remote server. This will be the same information our browser will be accessing on this page.
For example in the bellows, we have set up a variable named Gotothisurl which contains the URL of the Web page that we will ask our server to access. This visit should be saved to the variable responsepage.
<%
Gotothisurl = "http://www.111cn.net "
Set getconnection = CreateObject ("Microsoft.XMLHTTP")
Getconnection.open "Get", Gotothisurl, False
Getconnection.send
responsepage = Getconnection.responsetext
Response.Write (Responsepage)
Set getconnection = Nothing
%>
In Avobe For example, we might use a URL like http://111cn.net/mon/106/2e4f88e33c382feac03367f26ab889ad.htm. The above example will be obtained with the method. You can try http://www.google.asp?q=asp looking for ASP in Google search engine (unfortunatelly is not lawfully doing this to access their site unless we use the method shown in the script bellows).
In the above example, we require all content pages to be answered, but it may only require headers (check code bold script), but we can ask only for specific headings. You will need to change line Line 12 in the script:
Responsepage = Getconnection.getallresponseheaders
The response of the Web page will be something similar to this:
Server: microsoft-iis/5.0 Date: Thursday, April 31, 2002 14:25 20 seconds Greenwich Standard Time MICROSOFTOFFICEWEBSERVER:5.0_PUB connection: Keep active connection:
Guaranteed Content Length: 11063 content Type: text/HTML cache control: Private
We can also request specific sections of information including headings (periodic checks:
responsepage = Getconnection.getresponseheader ("Server")
To request for Date:
Responsepage= Getconnection.getresponseheader ("Date")
To request for Content Length:
responsepage = Getconnection.getresponseheader ("Content-length")
<%
' The address to be obtained
Gotothisurl = http://www.111cn.net
' Create an XML object
Set getconnection = CreateObject ("Microsoft.XMLHTTP")
' Connect host
Getconnection.open "Get", Gotothisurl, False
On Error Resume Next
Getconnection.send
' Responsepage's reaction we'll be in the interview
Responsepage = Getconnection.responsetext
' Start writing
if responsepage= "" then
Response.Write ("The page is not available")
Else
Response.Write (responsepage)
End If
Set getconnection = Nothing
%>