使用SQL定时触发VBSCRIPT脚本发送HTTP请求

test.vbs文件代码如下图:

 1  ScriptTimeout = 120
 2  function getHTTPPage(url) 
 3   on error resume next 
 4   dim http 
 5   set http=CreateObject("Microsoft.XMLHTTP") 
 6   Http.open "GET",url,false 
 7   Http.send() 
 8   if Http.readystate<>4 then
 9    exit function 
10   end if 
11   getHTTPPage=bytes2BSTR(Http.responseBody) 
12   set http=nothing
13   if err.number<>0 then err.Clear  
14  end function
15 
16  Function bytes2BSTR(vIn) 
17   dim strReturn 
18   dim i1,ThisCharCode,NextCharCode 
19   strReturn = "" 
20   For i1 = 1 To LenB(vIn) 
21    ThisCharCode = AscB(MidB(vIn,i1,1)) 
22    If ThisCharCode < &H80 Then 
23     strReturn = strReturn & Chr(ThisCharCode) 
24    Else 
25     NextCharCode = AscB(MidB(vIn,i1+1,1)) 
26     strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) 
27     i1 = i1 + 1 
28    End If 
29   Next 
30   bytes2BSTR = strReturn 
31  End Function 
32  
33  Function GetMid(txt,StrOne,StrTwo)
34  NumOne = Instr(txt,StrOne)
35  NumTwo = Instr(txt,StrTwo)
36  if NumOne=0 or NumTwo=0 Then GetMid="":Exit Function
37  GetMid = Mid(txt,NumOne+Len(StrOne),NumTwo-NumOne-Len(StrOne))
38  End Function
39  
40  Dim htmSource
41  htmSource=getHTTPPage("http://localhost/test/absa.asp")
View Code
原文地址:https://www.cnblogs.com/webczw/p/3366430.html