Detect headline change then notify
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Detect headline change then notify
Microsoft Windows 10 Pro
Microsoft Windows NT 10.0.18363.0
32-bit Operating System
Installed UI Culture: English (United States)
CLR version 4.0.30319.42000
Internet Explorer version 11.1198.18362.0
BrowserEmulation Mode = IE11
iMacros Browser (x86) version 12.6.505.4525
I'm trying to make a script that sends an email when the text on a page changes. I would manually enter the target text from a headline, for example:
https://imgur.com/v7nKAfr
I understand it's possible to use the TAG feature with EXTRACT but I'm not sure where to go from here.
TAG POS=1 TYPE=* ATTR=TXT:*Tencent<SP>Executive<SP>Held* EXTRACT=TXT
Any guidance would be appreciated. Thank you.
Microsoft Windows NT 10.0.18363.0
32-bit Operating System
Installed UI Culture: English (United States)
CLR version 4.0.30319.42000
Internet Explorer version 11.1198.18362.0
BrowserEmulation Mode = IE11
iMacros Browser (x86) version 12.6.505.4525
I'm trying to make a script that sends an email when the text on a page changes. I would manually enter the target text from a headline, for example:
https://imgur.com/v7nKAfr
I understand it's possible to use the TAG feature with EXTRACT but I'm not sure where to go from here.
TAG POS=1 TYPE=* ATTR=TXT:*Tencent<SP>Executive<SP>Held* EXTRACT=TXT
Any guidance would be appreciated. Thank you.
Re: Detect headline change then notify
set variable with initialise text
run macro in endless loop
{
Open page / refresh ( if already opened)
get text
compare text with variable set on top
if different quit loop
}
macro to send email
This will do one alert
can use vbs/js/VBA to do this
simple iMacros might not help
run macro in endless loop
{
Open page / refresh ( if already opened)
get text
compare text with variable set on top
if different quit loop
}
macro to send email
This will do one alert
can use vbs/js/VBA to do this
simple iMacros might not help
Last edited by techimac on Thu Feb 11, 2021 5:01 pm, edited 1 time in total.
Available for custom iim, javascript iMacros scripts
Re: Detect headline change then notify
TAG POS=1 TYPE=TAG_NAME_HERE ATTR=TXT:* EXTRACT=TXT
POS might need change its the TAG is not the 1st one on the webpage
Available for custom iim, javascript iMacros scripts
Re: Detect headline change then notify
Thank you for your reply.
Your answer combined with help from this post: viewtopic.php?t=27022
I was able to come up with this:
Do you think it would be possible to do something like this to send an email using only iMacros:
If VAR3 = PAGE HAS BEEN CHANGED
TAB T=2 (Open a new tab)
URL GOTO=gmail.com
Then compose email, enter subject, click send.
Else,
continue looping.
Your answer combined with help from this post: viewtopic.php?t=27022
I was able to come up with this:
Code: Select all
TAB T=1
SET !VAR1 "Headline to compare"
URL GOTO=example.com
SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var number1=\"{{!VAR1}}\"; var number2=\"{{!VAR2}}\"; if ( number1 = number2 ) {var x = \"NO CHANGE\";} else {var x=\"PAGE HAS BEEN CHANGED\";} x;")
PROMPT VAR1:<SP>{{!VAR1}}<BR><BR>VAR2:<SP>{{!VAR2}}<BR><BR>VAR3:<SP>{{!VAR3}}
If VAR3 = PAGE HAS BEEN CHANGED
TAB T=2 (Open a new tab)
URL GOTO=gmail.com
Then compose email, enter subject, click send.
Else,
continue looping.
Re: Detect headline change then notify
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_PAGE 30
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
TAB T=1
tab closeallothers
SET !VAR1 "Headline to compare"
URL GOTO=example.com
SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var number1=\"{{!VAR1}}\"; var number2=\"{{!VAR2}}\"; if ( number1 = number2 ) {var x = \"gmail.com\";} else {var x=\"\";} x;")
PROMPT VAR1:<SP>{{!VAR1}}<BR><BR>VAR2:<SP>{{!VAR2}}<BR><BR>VAR3:<SP>{{!VAR3}}
tab open
TAB T=2
URL GOTO={{!VAR3}}
use wait command in these steps because STEP is 0
TAB T=1
SET !TIMEOUT_PAGE 30
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
TAB T=1
tab closeallothers
SET !VAR1 "Headline to compare"
URL GOTO=example.com
SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var number1=\"{{!VAR1}}\"; var number2=\"{{!VAR2}}\"; if ( number1 = number2 ) {var x = \"gmail.com\";} else {var x=\"\";} x;")
PROMPT VAR1:<SP>{{!VAR1}}<BR><BR>VAR2:<SP>{{!VAR2}}<BR><BR>VAR3:<SP>{{!VAR3}}
tab open
TAB T=2
URL GOTO={{!VAR3}}
use wait command in these steps because STEP is 0
TAB T=1
Available for custom iim, javascript iMacros scripts
Re: Detect headline change then notify
using vbs will give more flexibility
Code: Select all
Option Explicit
Dim iim1, iret, Text, x
set iim1= CreateObject ("imacros")
iret = iim1.iimOpen("")
Text = "Headline to compare"
Dim m
m = m + "TAB T=1" + vbNewLine
m = m + "SET !ERRORIGNORE YES" + vbNewLine
m = m + "SET !TIMEOUT_PAGE 20" + vbNewLine
m = m + "SET !TIMEOUT_STEP 5" + vbNewLine
m = m + "TAB T=1" + vbNewLine
m = m + "TAB OPEN" + vbNewLine
m = m + "TAB T=2" + vbNewLine
m = m + "TAB CLOSEALLOTHERS" + vbNewLine
m = m + "URL GOTO=" + vbNewLine
m = m + "TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT"
Dim email
'write email macro
x = 1
Do While x > 0
iret = iim1.iimPlayCode(m)
if StrComp(trim(iim1.iimGetLastExtract()), Text) then iret = iim1.iimPlayCode(email)
Loop
Available for custom iim, javascript iMacros scripts
Re: Detect headline change then notify
Thank you. VBS looks to work much better especially with the email Macro.
One change I can't seem to figure out. I want the email macro to run only if text is NOT equal to the sample text (so it only sends email when there is a difference from the sample headline). Currently it is going to email macro if the text is equal so it's a constant loop.
One change I can't seem to figure out. I want the email macro to run only if text is NOT equal to the sample text (so it only sends email when there is a difference from the sample headline). Currently it is going to email macro if the text is equal so it's a constant loop.
Re: Detect headline change then notify
It was my mistake
Code: Select all
Option Explicit
Dim iim1, iret, Text, x
set iim1= CreateObject ("imacros")
iret = iim1.iimOpen("")
Text = "Headline to compare"
Dim m
m = m + "TAB T=1" + vbNewLine
m = m + "SET !ERRORIGNORE YES" + vbNewLine
m = m + "SET !TIMEOUT_PAGE 20" + vbNewLine
m = m + "SET !TIMEOUT_STEP 5" + vbNewLine
m = m + "TAB T=1" + vbNewLine
m = m + "TAB OPEN" + vbNewLine
m = m + "TAB T=2" + vbNewLine
m = m + "TAB CLOSEALLOTHERS" + vbNewLine
m = m + "URL GOTO=" + vbNewLine
m = m + "TAG POS=1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT"
Dim email
'write email macro
x = 1
Do While x > 0
iret = iim1.iimPlayCode(m)
if StrComp(trim(iim1.iimGetLastExtract()), Text) <> 0 then iret = iim1.iimPlayCode(email)
Loop
Available for custom iim, javascript iMacros scripts
Re: Detect headline change then notify
It seems to still loop to email macro even though the extract TXT is equal to sample text.
Should there be an ELSE statement so that when extract TXT is equal to sample text, it goes back to loop only the "Dim m" macro (and skips the "Dim email" macro)?
Sorry I am not good with syntax to produce this in code myself.
Should there be an ELSE statement so that when extract TXT is equal to sample text, it goes back to loop only the "Dim m" macro (and skips the "Dim email" macro)?
Sorry I am not good with syntax to produce this in code myself.
Re: Detect headline change then notify
Code: Select all
Option Explicit
Dim iim1, iret, Text1, x, Text2
set iim1= CreateObject ("imacros")
iret = iim1.iimOpen("")
Text1 = "Headline to compare"
Dim m
m = m + "TAB T=1" + vbNewLine
m = m + "SET !ERRORIGNORE YES" + vbNewLine
m = m + "SET !TIMEOUT_PAGE 20" + vbNewLine
m = m + "SET !TIMEOUT_STEP 5" + vbNewLine
m = m + "TAB T=1" + vbNewLine
m = m + "TAB OPEN" + vbNewLine
m = m + "TAB T=2" + vbNewLine
m = m + "TAB CLOSEALLOTHERS" + vbNewLine
m = m + "URL GOTO=" + vbNewLine
m = m + "TAG POS=1 TYPE=SPAN ATTR=* EXTRACT=TXT"
Dim email
'write email macro
email = email + "prompt Test" + vbNewLine
x = 1
Do While x > 0
iret = iim1.iimPlayCode(m)
Text2 = replace(trim(iim1.iimGetLastExtract(1)),"[EXTRACT]","")
if StrComp(Text1, Text2,vbTextCompare) <> 0 then iret = iim1.iimPlayCode(email)
Text1 = Text2
Loop
Available for custom iim, javascript iMacros scripts
Re: Detect headline change then notify
Thank you very much for the time you've taken to help me with this.