Help evaluating something on a webpage

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
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
Post Reply
hovisogden
Posts: 6
Joined: Wed Jan 22, 2014 12:26 am

Help evaluating something on a webpage

Post by hovisogden » Wed Jan 22, 2014 3:02 am

Hi,

I am new to this forum and relatively new to using iMacros for Firefox. I need to create a macro that will go to the following page:

http://www.galleryofguns.com/genie/Defa ... code=31313

and evaluate the text that is on it. On this page, where it says "Number Available:" and a number (right now it says "Number Available: 0"), I need it to evaluate the number that is there and, IF it is greater than 0, notify me by making a noise. I already know how to get the macro to make the noise:
(URL GOTO=file://C:\Windows\Media\chimes.wav). I'll need to use this for several other webpages, too, but I assume the steps will be the same. From what I understand, I'll probably need to use Java's Eval function? Or will I? If so, exactly what will the code look like? I know very little about writing code.

Any help would be greatly appreciated. Thanks in advance.
chivracq
Posts: 8871
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Help evaluating something on a webpage

Post by chivracq » Wed Jan 22, 2014 1:06 pm

Code: Select all

VERSION BUILD=8601111 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO

URL GOTO=http://www.galleryofguns.com/genie/Default.aspx?item=1293&mfg=Ruger&mdl=10%2f22&cat=All&type=All&cal=All&fin=&sit=&zipcode=31313
TAG POS=1 TYPE=B ATTR=TXT:Number<SP>Available:
'TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_mainContent_mainContentControl_lblQty
TAG POS=R1 TYPE=SPAN ATTR=ID:ctl00_mainContent_mainContentControl_lblQty EXTRACT=TXT

SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"0\") {var s = \"\";} else {var s = \"C:\\\Windows\\\Media\\\chimes.wav\";} s;")
'PROMPT !EXTRACT:<SP>{{!EXTRACT}}<br>!VAR1:<SP>{{!VAR1}}

URL GOTO=file://{{!VAR1}}
Change the '0' in the EVAL to '1' to test that it is working... (while the real Value on the Site is still "0"...!)

Tested on iMacros for FF v8.60, FF v26.0, WinXP SP3.

[EDIT]: Adding JFC-Meta-Tags:
conditional sound, DingDong
Last edited by chivracq on Sun Sep 07, 2014 6:31 am, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
hovisogden
Posts: 6
Joined: Wed Jan 22, 2014 12:26 am

Re: Help evaluating something on a webpage

Post by hovisogden » Thu Jan 23, 2014 12:33 am

Works perfectly. Thanks so much.
chivracq
Posts: 8871
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Help evaluating something on a webpage

Post by chivracq » Thu Jan 23, 2014 1:01 am

hovisogden wrote:Works perfectly. Thanks so much.
Good to hear. Enjoy...!
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
hovisogden
Posts: 6
Joined: Wed Jan 22, 2014 12:26 am

Re: Help evaluating something on a webpage

Post by hovisogden » Sat Jan 25, 2014 6:09 pm

Ok, I am now trying to adapt this to a different webpage and it is not working. Unfortunately, I can't provide the exact URL of the new webpage because I have to be logged into my account to use it. However, I have saved this webpage as an HTML document and I am attaching it to this post as a .zip file. Again, what I need this macro to do is go to the webpage and evaluate the text that is on it. On this page, where it says "Number Available:" and a number (right now it says "Number Available: 0"), I need it to evaluate the number that is there and, IF it is greater than 0, notify me by making a noise (and stop the macro, if possible). Here is what I have on this new, adapted macro:

-------------------------
VERSION BUILD=8601111 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP YES

URL GOTO=https://www.ellettbrothers.com/storefro ... tm_index=0
TAG POS=1 TYPE=TD ATTR=TXT:*
'TAG POS=1 TYPE=TD ATTR=TXT:*
TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT

SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"0\") {var s = \"\";} else {var s = \"C:\\\Windows\\\Media\\\chimes.wav\";} s;")
'PROMPT !EXTRACT:<SP>{{!EXTRACT}}<br>!VAR1:<SP>{{!VAR1}}

URL GOTO=file://{{!VAR1}}
------------------------
Note that I changed "SET !EXTRACT_TEST_POPUP NO" to "SET !EXTRACT_TEST_POPUP YES" to see what exactly the macro is extracting. Here is what it is extracting when I run it: "Please wait, loading real time pricing and inventory...". Then, as the macro finishes, it makes the ding sound (which it shouldn't be making, because the number there is currently "0"). One thing I've noticed about this macro, as opposed to the previous one, is that, when I record the macro and select the "0", the macro records "TAG POS=1 TYPE=TD ATTR=TXT:0" (I changed this to "TAG POS=1 TYPE=TD ATTR=TXT:*"). On the original macro (posted by chivracq in the second post), when recording, if you select the "0", you get this: "TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_mainContent_mainContentControl_lblQty", so apparently these pages are coded differently?

What am I doing wrong here?
Attachments
Macro Page 2.zip
(207.36 KiB) Downloaded 202 times
chivracq
Posts: 8871
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Help evaluating something on a webpage

Post by chivracq » Sat Jan 25, 2014 8:41 pm

Answer posted in the other Thread, no need to ask the same Question twice in 2 different Threads...
Help evaluating something else on a page
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply