Use XMLHTTP to detect URLs and Server Information

Source: Internet
Author: User

It mainly uses some methods and attributes of XMLHTTP to obtain server information.
The XMLHTTP object method and object attributes are attached to the following documents:
Http://www.csdn.net/Develop/article/16/16493.shtm
For more information about the status code, see my document "Internet HTTP connection and other error codes".
Http://www.csdn.net/Develop/Article/16/16477.shtm

The following are all source code:

<HTML>
<Head>
<Title> Use XMLHTTP to detect websites and server types </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 = "">
</Head>
<Body>
<Input type = "text" id = "jnkcinput" value = "http://www.csdn.net" size = "50"> <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 = "<HR> <PRE> <font color = Red>" & I & "," & jnkcurl & "</font> <br>" & jnkcstatus & "</ PRE> "& 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 = "this webpage does not exist! "
Elseif jnkcxmlhttp. Status <200 then
Jnkcstatus = "client error, message:" & CSTR (jnkcxmlhttp. Status) & "& jnkcxmlhttp. statustext
Elseif jnkcxmlhttp. Status <300 then
Jnkcstatus = "successful. This webpage can be accessed. "
Elseif jnkcxmlhttp. Status <400 then
Jnkcstatus = "redirection, information:" & CSTR (jnkcxmlhttp. Status) & "& jnkcxmlhttp. statustext
Elseif jnkcxmlhttp. Status <500 then
Jnkcstatus = "client error, message:" & CSTR (jnkcxmlhttp. Status) & "& jnkcxmlhttp. statustext
Elseif jnkcxmlhttp. Status <600 then
Jnkcstatus = "server error, message:" & CSTR (jnkcxmlhttp. Status) & "& jnkcxmlhttp. statustext
Else
Jnkcstatus = "Domain Name unavailable or network connection error, message:" & CSTR (jnkcxmlhttp. Status) & "& jnkcxmlhttp. statustext
End if
If jnkcxmlhttp. Status <600 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>
</Html>

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.