Using XMLHTTP to detect URLs and probe server information

Source: Internet
Author: User
Tags array object end error code header http request string domain name
The xml| server uses some of the XMLHTTP's methods and properties to get information about the server.
The XMLHTTP object methods and object properties are attached to the following article.
For a status code problem, you can see my other document, "Internet HTTP Connection error code encyclopedia"
Http://www.csdn.net/Develop/Article/16/16477.shtm

<title> using XMLHTTP detection URL and probe server information </title>
<meta http-equiv=content-type content= "text/html; charset=gb2312 ">
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "JNKC" >
<meta name= "Keywords" content= "" >
<body>
Please enter url:<input type= "text" id= "Jnkcinput" value= "http://" size= "" ><button id= "chk" > Detection </button>
<div id= "Jnkc_show" ></div>
<script language= "VBScript" >
Dim I,jnkcurl,jnkchtml,jnkcstatus,jnkcserver
Function Chk_onclick ()
Jnkcurl = Jnkcinput.value
Call Getdetail
i = i+1
jnkc_show.innerhtml = "End Function
Dim jnkcxmlhttp
Sub Getdetail
Set jnkcxmlhttp = CreateObject ("Microsoft.XMLHTTP")
Jnkcxmlhttp.onreadystatechange = GetRef ("GetStatus")
Jnkcxmlhttp.open "Get", Jnkcurl, False
On Error Resume Next
Jnkcxmlhttp.send
Set jnkcxmlhttp = Nothing
End Sub
Sub GetStatus
If jnkcxmlhttp.readystate <> 4 Then
Exit Sub
End If
If jnkcxmlhttp.status = 404 Then
Jnkcstatus = "The page does not exist!" "
ElseIf Jnkcxmlhttp.status < Then
Jnkcstatus = "Client error, Info:" & CStr (jnkcxmlhttp.status) & "" & Jnkcxmlhttp.statustext
ElseIf Jnkcxmlhttp.status < Then
Jnkcstatus = "Successful, the Web page can be accessed." "
ElseIf Jnkcxmlhttp.status < Then
Jnkcstatus = "Redirect, Info:" & CStr (jnkcxmlhttp.status) & "" & Jnkcxmlhttp.statustext
ElseIf Jnkcxmlhttp.status < Then
Jnkcstatus = "Client error, Info:" & CStr (jnkcxmlhttp.status) & "" & Jnkcxmlhttp.statustext
ElseIf Jnkcxmlhttp.status < Then
Jnkcstatus = "Server error, Info:" & CStr (jnkcxmlhttp.status) & "" & Jnkcxmlhttp.statustext
Else
Jnkcstatus = "Domain name unavailable or network connection error, Info:" & CStr (jnkcxmlhttp.status) & "" & Jnkcxmlhttp.statustext
End If
If Jnkcxmlhttp.status < Then call Getserver
End Sub
Sub Getserver
Jnkcserver = Jnkcxmlhttp.getresponseheader ("Server")
If jnkcserver <> "" Then
Jnkcstatus = jnkcstatus & "<br>http server:" & Jnkcserver
End If
Jnkcstatus = "<b>" & Jnkcstatus & "</b><br> all Feedback:<br>" & Jnkcxmlhttp.getallresponseheaders
End Sub
</SCRIPT>
</body>


Also attached:

ServerXMLHTTP Object method

Method description
Abort cancels the current HTTP request.
getAllResponseHeaders retrieves all header fields (header fields) from the response information.
getResponseHeader gets an HTTP header value from the body of the response message.
Open opens a connection to the HTTP server.
setRequestHeader set the header field of a request.
Send sends a request to the HTTP server. can contain body text.



ServerXMLHTTP Object Properties

Attribute Value Description
The onReadyStateChange event handler reference is for asynchronous operations only. Specifies the event handler that is invoked when the ready state changes, such as when the data is returned from the server.
The ReadyState integer describes the state of the asynchronous operation: uninitialized (0), loading (1), Loaded (2), Interaction (3), or completed (4).
The Responsebody variable array returns the body of the response information as an array.
Responsestream Istream returns the body of the response message as an ADO Stream object.
The ResponseText string returns the body of the response message as a text string.
The Responsexml XmlDocument object returns the body of the response message and is considered parsed by the MSXML XMLDOM parser.
Status Long is the HTTP state code returned by the server.
StatusText string HTTP response line state.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.