Monitoring Website For Keyword With Alert
Moderators: JRL, Dorian (MJT support)
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Monitoring Website For Keyword With Alert
Hi Guys,
I have been asked to look at creating a script that monitors a page (every 5 secs) http://paging1.sacfs.org/live/ for a few keywords and then if the word appears pops up a message box and plays a sound / file.
I have been using MS for a while, however never played much with WebPages.
Also note that the key words will appear on that page for a while, I don't want the alert to keep going off unless the word appears again.
Eg on that page if the word Aldinga appears, display message box, play sound. Waits for new reference of Aldinga to appear.
But I am after more than one word.
Looking at like 3-5 keywords.
Can anyone help.
I have MS v11 & v12. Currently do not have 13 yet. Can't afford it at the moment, I still use v11 for dialogs as I haven't got my head around them in v12.
I have been asked to look at creating a script that monitors a page (every 5 secs) http://paging1.sacfs.org/live/ for a few keywords and then if the word appears pops up a message box and plays a sound / file.
I have been using MS for a while, however never played much with WebPages.
Also note that the key words will appear on that page for a while, I don't want the alert to keep going off unless the word appears again.
Eg on that page if the word Aldinga appears, display message box, play sound. Waits for new reference of Aldinga to appear.
But I am after more than one word.
Looking at like 3-5 keywords.
Can anyone help.
I have MS v11 & v12. Currently do not have 13 yet. Can't afford it at the moment, I still use v11 for dialogs as I haven't got my head around them in v12.
FIREFIGHTER
Hi CyberCitizen,
The first thing I would do would be to use HTTPRequest> to pull the source of that web page into variable:
The above should work but it doesn't, I get the following error instead:
403 HTTP/1.1 403 Forbidden
However that url works just fine if you hit it from a browser...
Next steps anyone?
The first thing I would do would be to use HTTPRequest> to pull the source of that web page into variable:
Code: Select all
HTTPRequest>http://paging1.sacfs.org/live/,,GET,,HTMLResponse
MDL>HTMLResponse
403 HTTP/1.1 403 Forbidden
However that url works just fine if you hit it from a browser...
Next steps anyone?
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

A quick search of he forums found this post which has a solution supplied by Marcus:
http://www.mjtnet.com/forum/httprequest ... t6649.html
CyberCitizen, the following will work to pull in the html source for that site:
I also added three simple checks for various words... this should get you started.
Good luck and take care!
http://www.mjtnet.com/forum/httprequest ... t6649.html
Yes Marcus, I trust this issue is on the Wish List, but untill then, we have your VBScript work-around... used below.mtettmar wrote:I have also noted the issue with the user agent string. Web sites shouldn't really filter based on user agent, but never-the-less I'll see if we can change the user agent and/or make it over-ridable in a future release.
CyberCitizen, the following will work to pull in the html source for that site:
Code: Select all
VBSTART
Function HTTPGet(URL)
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate URL
do while IE.Busy
loop
HTTPGet = IE.document.documentelement.outerhtml
IE.quit
Set IE = Nothing
End Function
VBEND
VBEval>HTTPGet("http://paging1.sacfs.org/live/"),HTMLResult
MessageModal>HTMLResult
Label>check_1
Let>pattern=Aldinga
RegEx>pattern,HTMLResult,0,matches,num,0
If>num=0,check_2
MDL>%pattern% occured %num% time/s in the web page!
Label>check_2
Let>pattern=Adelaide
RegEx>pattern,HTMLResult,0,matches,num,0
If>num=0,check_3
MDL>%pattern% occured %num% time/s in the web page!
Label>check_3
Let>pattern=TRUCK ROLL
RegEx>pattern,HTMLResult,0,matches,num,0
MDL>%pattern% occured %num% time/s in the web page!
Good luck and take care!
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
How will you check to make sure its not a second copy of the first word that may have been removed? Need some typt of time monitor.
Suppose there are now multiple copies of the word, do you need to monitor that?
What if the word is in a different position because other words have been added or deleted?
You need to provide more specific specs about your constraints. Be exact about what you are looking for, providing examples with time constraints.
Suppose there are now multiple copies of the word, do you need to monitor that?
What if the word is in a different position because other words have been added or deleted?
You need to provide more specific specs about your constraints. Be exact about what you are looking for, providing examples with time constraints.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Hi Bob,
This page displays all the emergency response messages close to real time. When we get paged to respond to an emergency you will see our response message appear on this list.
The message will appear here approx 5-10 seconds after we are paged, however what we find is that the ambulance is paged before us, I am looking at a way of monitoring this page for the suburbs eg Aldinga.
So if the ambulance gets paged to Main South Road Aldinga we are most likely looking at getting called to the same job as that is a high impact area.
We are basically trying to get a ready response system so if we get an alert we can get our keys, car & gear ready so if we get a page we are out the door 30 seconds faster. Believe me it makes a big difference.
But yes as you mentioned I don't want the system to keep sending alerts if the word appears again and again.
Normally the same response message will go out 2-3 times, so 3x alerts are fine, however as it gets moved down the page with newer messages its position would change & we wouldn't want it alerting again until something different appeared.
I might be clutching at straws trying to get something like this going, but we are a volunteer brigade and anything we can do to assist our local residents we will try.
This page displays all the emergency response messages close to real time. When we get paged to respond to an emergency you will see our response message appear on this list.
The message will appear here approx 5-10 seconds after we are paged, however what we find is that the ambulance is paged before us, I am looking at a way of monitoring this page for the suburbs eg Aldinga.
So if the ambulance gets paged to Main South Road Aldinga we are most likely looking at getting called to the same job as that is a high impact area.
We are basically trying to get a ready response system so if we get an alert we can get our keys, car & gear ready so if we get a page we are out the door 30 seconds faster. Believe me it makes a big difference.
But yes as you mentioned I don't want the system to keep sending alerts if the word appears again and again.
Normally the same response message will go out 2-3 times, so 3x alerts are fine, however as it gets moved down the page with newer messages its position would change & we wouldn't want it alerting again until something different appeared.
I might be clutching at straws trying to get something like this going, but we are a volunteer brigade and anything we can do to assist our local residents we will try.
FIREFIGHTER
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Here is an overview approach that may help ...
Every five seconds Use HTTP to get the file.
USe Regex to find the line with the first instance of each key word
Parse out that line to grab the date/time
write the keyword and date/time to an ASC file to use as a database.
Run a SQL to count how mucn time elapsed for the last four instances of each keyword. If elapsed time is less than some defined period, then sound alarm.
========================
If you are creating the log, you could also take a similar approach when the log file is created. When creating the log, do the calculation for elapsed time then, and add a special char string to the line. Now you only need to search for that string in the last five seconds. Would work for all keywords.
Every five seconds Use HTTP to get the file.
USe Regex to find the line with the first instance of each key word
Parse out that line to grab the date/time
write the keyword and date/time to an ASC file to use as a database.
Run a SQL to count how mucn time elapsed for the last four instances of each keyword. If elapsed time is less than some defined period, then sound alarm.
========================
If you are creating the log, you could also take a similar approach when the log file is created. When creating the log, do the calculation for elapsed time then, and add a special char string to the line. Now you only need to search for that string in the last five seconds. Would work for all keywords.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
The script worked for me under MS 11 and 13 (that was what I have available at home) so I'm thinking it should work fine in MS 12 as well.CyberCitizen wrote:Thanks jpuziano,
What version of MS are you using? Wondering Marcus ever updated the user agent as it was back in Jan 2011.
No, Marcus must not have updated the user agent yet because the VBScript workaround is still required in MS version 13.1.06 which is currently the latest version available.
I believe this issue is on the Wish List... Marcus can you confirm this?
You should never loop the lines between:CyberCitizen wrote:I looked at the script you gave me, do I loop the VB part for IE? When I was running it, I was ending up with multiple iexplore processes.
- VBSTART
and...
VBEND
The following line, you would call as many times as you need to... each time you want to fetch the html source as it exists *right now*:
- VBEval>HTTPGet("http://paging1.sacfs.org/live/"),HTMLResult
- IE.quit
Set IE = Nothing
Keep in touch and let us know how you do on this one... it sounds like a very worthwhile project.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

The script worked for me under MS 11 and 13 (that was what I had at home) so I'm thinking it should work fine in MS 12 as well.CyberCitizen wrote:Thanks jpuziano,
What version of MS are you using? Wondering Marcus ever updated the user agent as it was back in Jan 2011.
No, Marcus must not have updated the user agent yet because the VBScript workaround is still required in MS version 13.1.06 which is currently the latest version available.
I believe this issue is on the Wish List... Marcus can you confirm this?
You should never loop the lines between:CyberCitizen wrote:I looked at the script you gave me, do I loop the VB part for IE? When I was running it, I was ending up with multiple iexplore processes.
- VBSTART
and...
VBEND
The following line you'd call as many times as you need to... each time you want to fetch the html source as it exists *right now*:
- VBEval>HTTPGet("http://paging1.sacfs.org/live/"),HTMLResult
- IE.quit
Set IE = Nothing
Keep in touch and let us know how you do on this one... it sounds like a very worthwhile project.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Thanks for the help guys.
I am getting further along. I am writing the results to a file every 5 seconds.
Then I am reading a line number to check if it contains the keywords specified. If it exists, it plays an alert & reads the message.
The issue I have now is I am trying to find what line number the HTML tag is on so I can reference it with the rest of the script.
What I am looking for is the first instance of this in the document
Replace the . with either forum wouldn't let me post it otherwise.
That is the line number I need to capture. I think I have a way of doing it, by reading each like and then checking with RegEx if that string existed if so that is my line number to start at.
Thoughts?
I am getting further along. I am writing the results to a file every 5 seconds.
Then I am reading a line number to check if it contains the keywords specified. If it exists, it plays an alert & reads the message.
The issue I have now is I am trying to find what line number the HTML tag is on so I can reference it with the rest of the script.
What I am looking for is the first instance of this in the document
Code: Select all
.TD class=message.
That is the line number I need to capture. I think I have a way of doing it, by reading each like and then checking with RegEx if that string existed if so that is my line number to start at.
Thoughts?
Code: Select all
Let>APP_TITLE=CFS Response Monitor
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
VBSTART
Function HTTPGet(URL)
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate URL
do while IE.Busy
loop
HTTPGet = IE.document.documentelement.outerhtml
IE.quit
Set IE = Nothing
End Function
VBEND
VBSTART
Sub Speak(text)
Dim Talk
Set Talk = CreateObject("SAPI.SpVoice")
Talk.Speak text
End Sub
VBEND
VBEval>HTTPGet("http://paging1.sacfs.org/live/"),HTMLResult
DeleteFile>%TEMP_DIR%CFSPagingData.txt
WriteLn>%TEMP_DIR%CFSPagingData.txt,WriteResult,%HTMLResult%
//It is here that I need to capture the line number in that case its 20
ReadLn>%TEMP_DIR%CFSPagingData.txt,20,FirstMSG
FIREFIGHTER
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia