- 相關推薦
如何利用XMLHTTP檢測URL及探測服務器信息
利用XMLHTTP檢測或監測URL,確認某個網頁或網站是否可以正常訪問?
如何利用XMLHTTP探測服務器信息?檢測網頁
Microsoft XML Version 2.0 (C:WinntSystem32msxml.dll)
Option Explicit
Private XmlHTTP As New XMLHTTPRequest
Private vUrl As String
Private vNumber As String
Private vDescription As String
Private vSource As String
Public Sub Connect()
On Error GoTo ErrorHandle:
XmlHTTP.Open \”Get\”, Url, False
XmlHTTP.send
ErrorHandle:
Call GetErrorHeadle(XmlHTTP)
End Sub
Private Sub GetErrorHeadle(ByRef XmlHTTP As XMLHTTPRequest)
If XmlHTTP.readyState <> 4 Then
Exit Sub
End If
If XmlHTTP.Status = 404 Then
Number = \”404\”
Description = \”該網頁不存在\”
ElseIf XmlHTTP.Status < 200 Then
Number = XmlHTTP.Status
Description = \”客戶端錯誤,信息:\” & CStr(XmlHTTP.Status) & \” \” & XmlHTTP.statusText
ElseIf XmlHTTP.Status < 300 Then
Number = XmlHTTP.Status
Description = \”成功,該網頁能訪問。\”
ElseIf XmlHTTP.Status < 400 Then
Number = XmlHTTP.Stauts
Description = \”重定向,信息:\” & CStr(XmlHTTP.Status) & \” \” & XmlHTTP.statusText
ElseIf XmlHTTP.Status < 500 Then
Number = XmlHTTP.Status
Description = \”客戶端錯誤,信息:\” & CStr(XmlHTTP.Status) & \” \” & XmlHTTP.statusText
ElseIf XmlHTTP.Status < 600 Then
Number = XmlHTTP.Status
Description = \”服務器錯誤,信息:\” & CStr(XmlHTTP.Status) & \” \” & XmlHTTP.statusText
Else
Number = XmlHTTP.Status
Description = \”域名不可用或網絡連接錯誤,信息:\” & CStr(XmlHTTP.Status) & \” \” & XmlHTTP.statusText
End If
If XmlHTTP.Status < 600 Then Call GetHTTPServer
End Sub
Private Sub GetHTTPServer()
Dim XmlServer As String
XmlServer = XmlHTTP.getResponseHeader(\”Server\”)
If XmlServer <> \”\” Then
Source = Source & \”HTTP服務器:\” & XmlServer
End If
Source = Source & \”所有反饋信息:\” & XmlHTTP.getAllResponseHeaders
End Sub
Public Property Get Number() As String
Number = vNumber
End Property
Public Property Let Number(ByVal Val As String)
vNumber = Val
End Property
Public Property Get Description() As String
Description = vDescription
End Property
Public Property Let Description(ByVal Val As String)
vDescription = Val
End Property
Public Property Get Url() As String
Url = vUrl
End Property
Public Property Let Url(ByVal Val As String)
vUrl = Val
End Property
Public Property Get Source() As String
Source = vSource
End Property
Private Property Let Source(ByVal Val As String)
vSource = Val
End Property
【如何利用XMLHTTP檢測URL及探測服務器信息】相關文章:
在英語教學中如何利用信息技術03-16
淺析如何利用信息技術課培養學生信息素養11-14
基于手機探測器的交通信息探測系統研究11-24
如何利用非信息技術為教學添加活力11-21
信息檢索與利用論文01-01
如何利用職場創業12-09
如何利用啞鈴健身09-16
如何利用簡歷模板05-18
高中數學課堂如何合理利用信息技術03-27
如何有效利用網絡學習12-29