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.

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.

Help evaluating something on a webpage

by hovisogden on Tue Jan 21, 2014 8:02 pm

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.
hovisogden
 
Posts: 6
Joined: Tue Jan 21, 2014 5:26 pm

Re: Help evaluating something on a webpage

by chivracq on Wed Jan 22, 2014 6:06 am

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 Sat Sep 06, 2014 11:31 pm, edited 1 time in total.
- (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: 6481
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Help evaluating something on a webpage

by hovisogden on Wed Jan 22, 2014 5:33 pm

Works perfectly. Thanks so much.
hovisogden
 
Posts: 6
Joined: Tue Jan 21, 2014 5:26 pm

Re: Help evaluating something on a webpage

by chivracq on Wed Jan 22, 2014 6:01 pm

hovisogden wrote:Works perfectly. Thanks so much.


Good to hear. Enjoy...!
- (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: 6481
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Help evaluating something on a webpage

by hovisogden on Sat Jan 25, 2014 11:09 am

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/storefrontB2BWEB/itemdetail.do?action=prepare_detail&itm_id=5596&itm_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 129 times
hovisogden
 
Posts: 6
Joined: Tue Jan 21, 2014 5:26 pm

Re: Help evaluating something on a webpage

by chivracq on Sat Jan 25, 2014 1: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)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: 6481
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: Bing [Bot] and 6 guests

-->