Simple Extraction Question. Back to Basics for me!

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Simple Extraction Question. Back to Basics for me!

Post by additional001 » Thu Nov 20, 2014 1:33 pm

I used to be a very active member of the iMacro's for FF community back in 2008-2009 but I stopped using it for sometime for a few reasons. Partly because of frustration and partly because the site I was writing scripts on changed and I lost interest(in the site).

Well now I have a new desire to automate some things and so I've picked back up the torch (for iMacros).

I am unbelievably rusty at scripting. I think I have forgotten almost everything. I'm hoping to get back up to speed but I've run into something that seems odd to me. All I want to do is a simple HREF extract on a button. After extracting the HREF I want to store it as a variable for later conditional comparison.

This was recorded when clicking on it...

Code: Select all

TAG POS=1 TYPE=A ATTR=HREF:/p/login&&ID:sbGlobalNavLoginBtn
Here is my code...

Code: Select all

var SBHome
var SBLogin
var SBLoginURL
var nL="\n"
var i

SBHome = "CODE:"
SBHome = SBHome+"TAB T=1" + nL
SBHome = SBHome+"TAB CLOSEALLOTHERS" + nL
SBHome = SBHome+"URL GOTO=http://www.swagbucks.com/p/login" + nL
iimDisplay("We need to close ALL tabs now.")
iimPlay(SBHome)

SBLogin = "CODE:"
SBLogin = SBLogin+"TAG POS=1 TYPE=A ATTR=HREF:/p/login&&ID:sbGlobalNavLoginBtn EXTRACT=HREF"
SBLoginURL = iimGetExtract(1)
alert(SBLoginURL)
The extraction is not showing up. I've tried both alert and iimDisplay to display it. Shouldn't it just be setting the /p/login as the HREF and then setting that to SBLoginURL? What am I missing here? This should just be a cheap and easy way to verify if the button is there (that is if I can ever get it to set the variable to compare with).

The button can be viewed here..

http://www.swagbucks.com/?gw=1
skippyto
Posts: 108
Joined: Wed Aug 20, 2008 8:14 am

Re: Simple Extraction Question. Back to Basics for me!

Post by skippyto » Thu Nov 20, 2014 2:09 pm

Hi additional001 !

I think what you are searching for is here : http://wiki.imacros.net/iimGetLastExtract%28%29

For example, to extract the text of the "button" "Get Started" :

Code: Select all

TAG POS=1 TYPE=DIV ATTR=ID:newNext EXTRACT=TXT
I you want to check the extracted value in your iim script to debug, you can use the following code :

Code: Select all

PROMPT {{!EXTRACT}}
By the way, if you just want to check the presence of the button, the following code is enough :

Code: Select all

TAG POS=1 TYPE=DIV ATTR=ID:newNext CONTENT=EVENT:MOUSEOVER
And you'll get an error ending your iim macros if the button is not there.

And don't forget to play (iimplay) your iim macro before trying to get the extracted value !

Hope this help !

Skippyto.
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Simple Extraction Question. Back to Basics for me!

Post by additional001 » Thu Nov 20, 2014 3:32 pm

skippyto wrote:
I think what you are searching for is here : http://wiki.imacros.net/iimGetLastExtract%28%29
iimGetLastExtract is depreciated. if you look at the page you directed me to the very first line is Name change: Please use iimGetExtract instead. See API enhancements for details.
For example, to extract the text of the "button" "Get Started" :

Code: Select all

TAG POS=1 TYPE=DIV ATTR=ID:newNext EXTRACT=TXT
I you want to check the extracted value in your iim script to debug, you can use the following code :

Code: Select all

PROMPT {{!EXTRACT}}
Unless things have changed I shouldn't have to do this. I should be able to interact directly with EXTRACT(ed) data by using iimGetExtract (or formerly iimGetLastExtract as I used to use). I would prefer to stay on more with javascript side code than I would having to work within iim code.
By the way, if you just want to check the presence of the button, the following code is enough :

Code: Select all

TAG POS=1 TYPE=DIV ATTR=ID:newNext CONTENT=EVENT:MOUSEOVER
And you'll get an error ending your iim macros if the button is not there.
It's more than just checking if it's there. I need to check if it's there and if it is I need that HREF code (as a variable) to do conditional checking latter.
And don't forget to play (iimplay) your iim macro before trying to get the extracted value !

Hope this help !

Skippyto.
:facepalm LOL you may be on to something there! I'll test that out. Thanks! :D
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Simple Extraction Question. Back to Basics for me!

Post by additional001 » Thu Nov 20, 2014 3:43 pm

Thanks Skippyto. It was indeed a matter of performing the iimPlay before trying to set the variable... corrected code follows.

Code: Select all

var SBHome
var SBLogin
var SBLoginURL
var nL="\n"
var i

SBHome = "CODE:"
SBHome = SBHome+"TAB T=1" + nL
SBHome = SBHome+"TAB CLOSEALLOTHERS" + nL
SBHome = SBHome+"URL GOTO=http://www.swagbucks.com/?gw=1" + nL
iimDisplay("We need to close ALL tabs now.")
iimPlay(SBHome)

SBLogin = "CODE:"
SBLogin = SBLogin+"TAG POS=1 TYPE=A ATTR=HREF:/p/login&&ID:sbGlobalNavLoginBtn EXTRACT=HREF"
iimPlay(SBLogin)

SBLoginURL = iimGetExtract(1)

alert(SBLoginURL)
skippyto
Posts: 108
Joined: Wed Aug 20, 2008 8:14 am

Re: Simple Extraction Question. Back to Basics for me!

Post by skippyto » Fri Nov 21, 2014 3:21 pm

Sorry for iimGetLastExtract.

I am an old user of iMacros for a long time, and (having many script to update) I never switch to iimGetLastExtract to iimGetExtract because they don't have the same behavior...

Skippyto.
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Simple Extraction Question. Back to Basics for me!

Post by additional001 » Fri Nov 21, 2014 7:37 pm

skippyto wrote:I never switch to iimGetLastExtract to iimGetExtract because they don't have the same behavior..
LOL yeah I noticed that too! Why in the world are they telling us to use something new that doesn't work correctly!?!?!?
Post Reply