For Each Prog In arrProgId If (IsObjInstalled(Prog) = true) Then XmlHttpCom = Prog Exit For End If Next
'// summary> '// Rem 檢查組件是否支持 是返回 True 否返回 False '// /summary> Public Function IsObjInstalled(strClassString) On Error Resume Next
'//設置初始化值
IsObjInstalled = False Err = 0
'//測試代碼
Dim xTestObj Set xTestObj = Server.createObject(strClassString) If 0 = Err Then IsObjInstalled = True
'//清除所申請的對象
Set xTestObj = Nothing Err = 0 End Function
上面那段代碼就是申請到當前服務器支持的最高版本的XMLHTTP對象了
下面我們講一下采集功能函數(shù)
'GetFileText為采集功能函數(shù) Public Function GetFileText(url) on error resume next '有錯誤時繼續(xù)執(zhí)行代碼 Dim http '定義變量 'Set http=Server.createobject(XmlHttpCom) '申請對象 Set http=Server.createobject("Microsoft.XMLHTTP") '保險起見,寫出一個服務器一般都支持的版本 Http.open "GET",url,False '打開對象 用GET方式 等待服務器響應 Http.Send() '發(fā)送 If Http.readystate>4 Then '如果服務器沒反應,則退出函數(shù) Exit Function End If