Play sound if value is below of $50

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Play sound if value is below of $50

by nexitorned on Tue Feb 13, 2018 1:57 am

Hello to everyone, actually i'm trying to make a imacro who compare if value is below of $50 and if it is in stock (Text), if it's, make an alert. If not, continue to next TAB (Another web page) until find it.

The only thing I can do, is that find a text, make an alert/sound (It works) but I do not know how to compare it with a value and play sound.

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL

TAB T=1
URL GOTO=https://www.amazon.com/Headphones-Vibration-Microphone-Isolating-Breathing/dp/B073RFDD16
TAG POS=1 TYPE=SPAN ATTR=TXT:In<SP>Stock. EXTRACT=TXT
SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"In Stock.\") {var s = 'C:/rawayan.mp3';} else {var s = \"\";} s;")
'PROMPT !EXTRACT:In<SP>Stock.{{!EXTRACT}}<br>!VAR1:In<SP>Stock.{{!VAR1}}
TAB OPEN
TAB T=2
URL GOTO=file://{{!VAR1}}


PD: I found a way to remove $ symbol of amazon to extract the number but don't work the code in general.

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL

TAB T=1
URL GOTO=https://www.amazon.com/Headphones-Vibration-Microphone-Isolating-Breathing/dp/B073RFDD16
TAG POS=1 TYPE=SPAN ATTR=ID:priceblock_ourprice EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !VAR2 50
SET !VAR3 EVAL("var s=\"{{!EXTRACT}}\"; x=s.replace(\"$\",\"\"); x;")
SET !VAR4 EVAL("var n1='{{!VAR3}}', n2='{{!VAR2}}'; if((n1*1)<(n2*1)) then (\"{{!EXTRACT}}\")  {var s = 'C:/rawayan.mp3';} else {var s = \"\";} s;")
TAB T=2
URL GOTO=file://{{!VAR3}}
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_


Give me !VAR4: Undefined and don't play the music :oops:

Imacros 9.0.3
Firefox 54.0
Windows 10 64-Bit
Last edited by nexitorned on Tue Feb 13, 2018 1:26 pm, edited 1 time in total.
nexitorned
 
Posts: 3
Joined: Tue Feb 13, 2018 1:45 am

Re: Play sound if value is below of $50

by chivracq on Tue Feb 13, 2018 4:09 am

nexitorned wrote:Hello to everyone, actually i'm trying to make a imacro who compare if value is below of $50 and if it is in stock (Text), if it's, make an alert. If not, continue to next TAB (Another web page) until find it.

The only thing I can do, is that find a text, make an alert/sound (It works) but I do not know how to compare it with a value and play sound.

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL

TAB T=1
URL GOTO=https://www.amazon.com/Headphones-Vibration-Microphone-Isolating-Breathing/dp/B073RFDD16
TAG POS=1 TYPE=SPAN ATTR=TXT:In<SP>Stock. EXTRACT=TXT
SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"In Stock.\") {var s = 'C:/rawayan.mp3';} else {var s = \"\";} s;")
'PROMPT !EXTRACT:In<SP>Stock.{{!EXTRACT}}<br>!VAR1:In<SP>Stock.{{!VAR1}}
TAB OPEN
TAB T=2
URL GOTO=file://{{!VAR1}}


PD: I found a way to remove $ symbol of amazon to extract the number but don't work the code in general.

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL

TAB T=1
URL GOTO=https://www.amazon.com/Headphones-Vibration-Microphone-Isolating-Breathing/dp/B073RFDD16
TAG POS=1 TYPE=SPAN ATTR=ID:priceblock_ourprice EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !VAR2 50
SET !VAR3 EVAL("var s=\"{{!EXTRACT}}\"; x=s.replace(\"$\",\"\"); x;")
SET !VAR4 EVAL("var n1='{{!VAR3}}', n2='{{!VAR2}}'; if((n1*1)<(n2*1)) then (\"{{!EXTRACT}}\")  {var s = 'C:/rawayan.mp3';} else {var s = \"\";} s;")
TAB T=2
URL GOTO=file://{{!VAR3}}
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_


Give me !VAR4: Undefined and don't play the music :oops:

CIM...! :mrgreen: (Read my Sig...)

Oh..., but I see you are making some Progress, good...! (A bit "dangerous" by the way to "silently" edit your Post(s), you can better post an Update... (except for adding your FCI)...)

Yep, you are very close, the "most difficult" part was the "Conditional Sound", and I see you've located a good Thread where I had helped for a Numerical Comparison... Now you only need to find the '&&' Operator...! :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6960
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Play sound if value is below of $50

by nexitorned on Tue Feb 13, 2018 1:27 pm

chivracq wrote:
nexitorned wrote:Hello to everyone, actually i'm trying to make a imacro who compare if value is below of $50 and if it is in stock (Text), if it's, make an alert. If not, continue to next TAB (Another web page) until find it.

CIM...! :mrgreen: (Read my Sig...)

Oh..., but I see you are making some Progress, good...! (A bit "dangerous" by the way to "silently" edit your Post(s), you can better post an Update... (except for adding your FCI)...)

Yep, you are very close, the "most difficult" part was the "Conditional Sound", and I see you've located a good Thread where I had helped for a Numerical Comparison... Now you only need to find the '&&' Operator...! :idea:



Sorry i didn't know about update button, CIM added. Still any progress yet, this issue is killing me :(
nexitorned
 
Posts: 3
Joined: Tue Feb 13, 2018 1:45 am

Re: Play sound if value is below of $50

by chivracq on Tue Feb 13, 2018 4:00 pm

nexitorned wrote:Sorry i didn't know about update button, CIM added. Still any progress yet, this issue is killing me :(

Ah OK, good for your FCI:
Code: Select all
Imacros 9.0.3
Firefox 54.0
Windows 10 64-Bit


Well, like I said, you are very close, you've already done the most "difficult" part(s), and you even already have the "x1" Trick (from the Thread about Comparison that you managed to locate) to make sure to compare the Price arithmetically (and not alphabetically, which often happens from Extracts, in which case, "99<50" would be False like you expect but "100<50" would still be True, and "9<50" would be False, oops...!)...

Now you only need to use the '&&' (= "Logical AND") Operator to combine your 2 Conditions together for the 'if' part... That's the easiest part...!
chivracq
 
Posts: 6960
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Play sound if value is below of $50

by nexitorned on Tue Feb 13, 2018 6:40 pm

Ok now it's working but i don't know how to check all the POS (Prices) on the page, not only one.

With this code only take one and stop, but i want to check all on the web and PLAY the song if meet the requeriment value > 100 (!VAR4) and less than 322 (!VAR 2) if not continue...

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL
SET !LOOP 10

TAG POS=1 TYPE=SPAN ATTR=CLASS:sx-price-whole
SET !VAR1 {{!EXTRACT}}
SET !VAR2 322

SET !VAR3 100
SET !VAR4 EVAL("var n1='{{!VAR1}}', n2='{{!VAR2}}', n3='{{!VAR3}}'; if((n1*1)<(n2*1) && (n2*1)<(n3*1)){var h = 'C:/rawayan.mp3';} else {var h = \"\";} h;")

PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_<br>!EXTRACT:<SP>_{{!EXTRACT}}_<br>
URL GOTO=file://{{!VAR4}}


This code search all the POS on the page but 'if' isn't working so this thing, isn't playing the sound.

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL
SET !LOOP 10

TAG POS={{!LOOP}} TYPE=SPAN ATTR=CLASS:sx-price-large
TAG POS=1 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=2 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT 
TAG POS=3 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=4 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=5 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=6 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT 
TAG POS=7 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=8 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=9 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=10 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT 
TAG POS=11 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=12 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT

SET !VAR1 {{!EXTRACT}}
SET !VAR2 600

SET !VAR3 100
SET !VAR4 EVAL("var n1='{{!VAR1}}', n2='{{!VAR2}}', n3='{{!VAR3}}'; if((n1*1)<(n2*1)) && (n2*1)<(n3*1))  {var h = 'C:/rawayan.mp3';} else {var h = \"\";} h;")


URL GOTO=file://{{!VAR4}}
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_<br>!EXTRACT:<SP>_{{!EXTRACT}}_<br>VAR5:<SP>_{{!VAR5}}_<br>



More than 24 hours doing this thing, i want to kill my self seriously and still don't work, f**** my life :oops:
nexitorned
 
Posts: 3
Joined: Tue Feb 13, 2018 1:45 am

Re: Play sound if value is below of $50

by chivracq on Wed Feb 14, 2018 12:02 pm

nexitorned wrote:Ok now it's working but i don't know how to check all the POS (Prices) on the page, not only one.

With this code only take one and stop, but i want to check all on the web and PLAY the song if meet the requeriment value > 100 (!VAR4) and less than 322 (!VAR 2) if not continue...

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL
SET !LOOP 10

TAG POS=1 TYPE=SPAN ATTR=CLASS:sx-price-whole
SET !VAR1 {{!EXTRACT}}
SET !VAR2 322

SET !VAR3 100
SET !VAR4 EVAL("var n1='{{!VAR1}}', n2='{{!VAR2}}', n3='{{!VAR3}}'; if((n1*1)<(n2*1) && (n2*1)<(n3*1)){var h = 'C:/rawayan.mp3';} else {var h = \"\";} h;")

PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_<br>!EXTRACT:<SP>_{{!EXTRACT}}_<br>
URL GOTO=file://{{!VAR4}}


This code search all the POS on the page but 'if' isn't working so this thing, isn't playing the sound.

Code: Select all
SET !TIMEOUT_STEP 2
SET !TIMEOUT_PAGE 2
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET EXTRACT NULL
SET !LOOP 10

TAG POS={{!LOOP}} TYPE=SPAN ATTR=CLASS:sx-price-large
TAG POS=1 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=2 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT 
TAG POS=3 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=4 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=5 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=6 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT 
TAG POS=7 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=8 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=9 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=10 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT 
TAG POS=11 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT
TAG POS=12 TYPE=SPAN ATTR=CLASS:sx-price-whole EXTRACT=TXT

SET !VAR1 {{!EXTRACT}}
SET !VAR2 600

SET !VAR3 100
SET !VAR4 EVAL("var n1='{{!VAR1}}', n2='{{!VAR2}}', n3='{{!VAR3}}'; if((n1*1)<(n2*1)) && (n2*1)<(n3*1))  {var h = 'C:/rawayan.mp3';} else {var h = \"\";} h;")

URL GOTO=file://{{!VAR4}}
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_<br>!EXTRACT:<SP>_{{!EXTRACT}}_<br>VAR5:<SP>_{{!VAR5}}_<br>


More than 24 hours doing this thing, i want to kill my self seriously and still don't work, f**** my life :oops:

Hum, "it's working...", I'm a bit surprised, because your first Script in this last Post is not the/a Solution to your original Qt in this Thread... and not to "100<Price<322" either... And there is no 'CLASS:sx-price-whole' Element on the Page you posted the URL of...
But OK, you've finally found and understood how to use the '&&' Operator, good-good-good, and you use 'PROMPT' very correctly to follow your Vars and debug your Script, so I guess you will come out by yourself...

>

Your '!TIMEOUT_STEP' Statement is useless btw, as you have a '!TIMEOUT_PAGE' Statement just after it. It must be the other way around...

And your "SET EXTRACT NULL" is useless as well, ...
1- the correct Spelling is "!EXTRACT" for the Name of the Var (and not "EXTRACT") but ...
2- even if you had spelt it correctly, it has no Use at the beginning of a Script as the '!EXTRACT' Var is already always empty.
The correct place is always just before (or just after) an 'EXTRACT'.
And sometimes if you want to add an empty Line in your '.CSV' with a 'SAVEAS', but '!EXTRACT' is theoretically already empty at that moment.

>>>

For your 2nd Qt/Script, well I don't know, it's getting a bit "messy" ah-ah...!, too many "things" have changed from your OP, and it's a completely new Qt, open a new (Standalone) Thread I would say, with all Info...
But I think you should first read a bit of Documentation about how the 'Loop' Mechanism works in iMacros... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6960
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: Google [Bot] and 3 guests

-->