在网页上查找值和 Returns 消息提示的 VBScript
VBScript That Finds A Value on a Webpage and Returns a Message Prompt
我正在尝试创建一个脚本来检查内部网站是否有可用的许可证,并向用户报告是否有可用许可证的消息提示。网站搜索工作正常,但是,我无法正确格式化第二条消息提示。
如果我发送命令搜索“使用了 5 个许可证”,我需要一条消息提示没有可用的许可证。如果该值不匹配,则说明有可用的许可证。
如有必要,可以重写整个脚本。不需要是一个循环。就想要这个工作功能。
Do
Find "5 Licenses used","websiteaddress.com"
Pause("60")'waiting for 60 minutes and repeat the action
Loop
Function Find(StrString,URL)
Title = "License Check"
'URL = "Websiteaddress.com"
Set ie = CreateObject("InternetExplorer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
ie.Navigate(URL)
ie.Visible = false 'run ie in the background
Do While ie.Busy
WScript.Sleep 100
Loop
Data = ie.document.documentElement.innertext
Set ie = Nothing
Set objRegex = New RegExp
objRegex.Pattern = StrString
objRegex.Global = False
objRegex.IgnoreCase = True
Set Matches = objRegex.Execute(Data)
For Each Match in Matches
MsgBox "There Are Currently No Licenses Available " & URL, 64, Title
Next
If
'No Match in Matches
MsgBox "There Are Licenses Available " & URL, 64, Title
End If
End Function
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function
Function Pause(NbMin)
WScript.Sleep NbMin*1000*60
End Function
计算匹配项。
If Matches.Count > 0 Then
MsgBox "There Are Currently No Licenses Available " & URL,64,Title
Else
MsgBox "There Are Licenses Available " & URL, 64,Title
End If
我正在尝试创建一个脚本来检查内部网站是否有可用的许可证,并向用户报告是否有可用许可证的消息提示。网站搜索工作正常,但是,我无法正确格式化第二条消息提示。 如果我发送命令搜索“使用了 5 个许可证”,我需要一条消息提示没有可用的许可证。如果该值不匹配,则说明有可用的许可证。
如有必要,可以重写整个脚本。不需要是一个循环。就想要这个工作功能。
Do
Find "5 Licenses used","websiteaddress.com"
Pause("60")'waiting for 60 minutes and repeat the action
Loop
Function Find(StrString,URL)
Title = "License Check"
'URL = "Websiteaddress.com"
Set ie = CreateObject("InternetExplorer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
ie.Navigate(URL)
ie.Visible = false 'run ie in the background
Do While ie.Busy
WScript.Sleep 100
Loop
Data = ie.document.documentElement.innertext
Set ie = Nothing
Set objRegex = New RegExp
objRegex.Pattern = StrString
objRegex.Global = False
objRegex.IgnoreCase = True
Set Matches = objRegex.Execute(Data)
For Each Match in Matches
MsgBox "There Are Currently No Licenses Available " & URL, 64, Title
Next
If
'No Match in Matches
MsgBox "There Are Licenses Available " & URL, 64, Title
End If
End Function
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function
Function Pause(NbMin)
WScript.Sleep NbMin*1000*60
End Function
计算匹配项。
If Matches.Count > 0 Then
MsgBox "There Are Currently No Licenses Available " & URL,64,Title
Else
MsgBox "There Are Licenses Available " & URL, 64,Title
End If