How To Verify Tag Exists before Attempting to Access Page

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
magnetsa
Posts: 13
Joined: Sun Jul 20, 2014 2:28 am

How To Verify Tag Exists before Attempting to Access Page

Post by magnetsa » Sun Dec 21, 2014 5:09 pm

I access perhaps a couple hundred web pages a day using iMacros. Thanks!!!

Over time things change and some pages are no longer accessible. For example, "TAG POS=1 TYPE=A ATTR=TXT:7" and "TAG POS=1 TYPE=A ATTR=TXT:8" might work fine one day but the next day "TAG POS=1 TYPE=A ATTR=TXT:8" points to a page 8 that no longer exists.

That is where the problem starts. Because if I attempt to use "TAG POS=1 TYPE=A ATTR=TXT:8" I get an error response page that terminates my use of their website temporarily. How can I use iMacros to test for the "8" attribute in the existing page 7 web page before attempting to go to page 8 (which does not exist)?

Once I can determine page 8 does not exist, then I would want to terminate the macro.
chivracq
Posts: 9186
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How To Verify Tag Exists before Attempting to Access Pag

Post by chivracq » Thu Dec 25, 2014 4:10 am

magnetsa wrote:I access perhaps a couple hundred web pages a day using iMacros. Thanks!!!

Over time things change and some pages are no longer accessible. For example, "TAG POS=1 TYPE=A ATTR=TXT:7" and "TAG POS=1 TYPE=A ATTR=TXT:8" might work fine one day but the next day "TAG POS=1 TYPE=A ATTR=TXT:8" points to a page 8 that no longer exists.

That is where the problem starts. Because if I attempt to use "TAG POS=1 TYPE=A ATTR=TXT:8" I get an error response page that terminates my use of their website temporarily. How can I use iMacros to test for the "8" attribute in the existing page 7 web page before attempting to go to page 8 (which does not exist)?

Once I can determine page 8 does not exist, then I would want to terminate the macro.
Consider reading once the Forum Rules and my Sig, and you'll improve consistently the Answer-Rate to your Threads like I've already asked in some other Thread...

From your other Threads you sound like you are quite technical, Question in this current Thread relates to a fairly basic Use of iMacros that you should master by now..., have a look at the Command Reference..., especially the "magic" Commands 'EXTRACT' and 'EVAL()'... :idea:
- (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...
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: How To Verify Tag Exists before Attempting to Access Pag

Post by additional001 » Mon Jan 05, 2015 6:58 am

Forgive chivracq for his FCIM rant. He's a bit anal retentive when it comes to that. LOL Usually justifiably so but in this case it's really not needed for an answer.

I can't give you code answer but I can give you a logistical one. What you are asking for can not be done with just iMacro code alone. You need another scripting language to do it. Most people here use JavaScript or VBS but others are possible as well. The reason you need a scripting language is that you need to use a conditional to evaluate the situation.

You need to perform an extraction, set that extraction to a variable, and then use that variable to evaluate the outcome of that extracted variable with a conditional such as an if then else statement.

Logically it would look something like this... Please note this is FAR from syntactically correct but it should give you an idea of the logic.

TAG POS=1 TYPE=A ATTR=TXT:8 EXTRACT=HTM
iimGetLastExtract(1) = myVar

if (myVar == this) {
do this
}
elseif ( myVar == that) {
do something else
}

Once you decide on a scripting language and you want help with syntax I'm sure people would be glad to help further... and at that point be sure to provide FCIM :) I would suggest JavaScript though as it is easily usable with in iMacros for FF.
chivracq
Posts: 9186
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How To Verify Tag Exists before Attempting to Access Pag

Post by chivracq » Mon Jan 05, 2015 8:35 am

additional001 wrote:What you are asking for can not be done with just iMacro code alone.
Not true... (It can be done...) :roll:
- (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...
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: How To Verify Tag Exists before Attempting to Access Pag

Post by additional001 » Fri Jan 09, 2015 1:49 pm

Right I'm still used to pre EVAL. Given that the iimGetExtract doesn't work right I'm going to assume EVAL doesn't work right and keep using old methods that have worked for me in the past... untill they break those.
Post Reply