VBScript Interaction With Website
I'm trying to write a VBScript that can talk to opmanager and get the stats of specific servers/devices/etc by a quick call. I've wrote one that occasionally works and can very rarely pull the appropriate data from the snapshot page, but its obviously having issues loggin in. As I'm no web interaction guru with vbscript and have no idea how to deal with ".do" files, is there any way ya'll can assist in getting this script working? I've enclosed it below:
Set Args = WScript.Arguments
Set objHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
username=admin
password=admin
'Login (its not logging on here correctly to get the status page later)
objHTTP.Open "POST", "http://opsmon01/Login.do",False,username,password
objHTTP.send
wscript.Echo "POST: " & objHTTP.statusText
'Get Status Page
objHTTP.Open "GET", "http://opsmon01/devices/objectdetails.do?requestid=SNAPSHOT&name=" & Args(0),False
objHTTP.Send
wscript.Echo "GET: " & objHTTP.statusText
returnStr = objHTTP.ResponseText
WScript.Echo "Returned " & Len(returnStr) & " Bytes"
'This parses the return string looking for the status string
Index = InStr(1,returnStr,"<td width=60% align=" & """" & "left" & """" & " class=" & """" & "txtGlobal" & """" & "><img src=" & """" & "/webclient/devices/images",1)
If index=0 Then
WScript.Echo "Didn't Find String!"
WScript.Quit
End If
StartIndex = InStr(Index,ReturnStr,";",1)
StopIndex = InStr(Index,ReturnStr,"
",1)
If index>0 Then
Wscript.echo Args(0) & ": " & Mid(ReturnStr,StartIndex+1,StopIndex-StartIndex-1)
Else
WScript.Echo "Post Failed!"
End If
New to ADSelfService Plus?