Using SEARCH SOURCE=TXT

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
leegold
Posts: 8
Joined: Wed Oct 27, 2010 9:04 am

Using SEARCH SOURCE=TXT

Post by leegold » Sat Jul 23, 2011 3:16 am

Hi,

I'm looking at the following SEARCH example and I can not make sense of it:

Code: Select all

URL GOTO=http://iopus.com/
 'Check for Script
 SEARCH SOURCE=TXT:"_gat._getTracker(\"UA-336765-1\")"  ' <--  line 1 --<
 'Check for Script, ignore case
 SEARCH SOURCE=TXT:"_gettracker" IGNORE_CASE=YES
 'Use regular expression to extract data
 SEARCH SOURCE=REGEXP:"_get[Tt]racker\\(([^)]+)\\)" EXTRACT="Tracker is $1"
 'Display extracted data
 PROMPT {{!EXTRACT}}
What does line 1 do? If the pattern is found does "SOURCE" get set to "True" or does "SOURCE" get set to the string being searched for if the string is found? It's not clear what happens if the string is found or not found. What is changing based on a success or non-success of the search? No obvious action is being taken in the example based on the "SEARCH" result on line 1 so the example is leaving me hanging in the air and confused.

The "SEARCH SOURCE=REGEXP:" line is clear to me. I just need help understand what purpose is for line 1. Thanks.
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Using SEARCH SOURCE=TXT

Post by MattBell7 » Sat Jul 23, 2011 12:49 pm

SOURCE is not a variable, its a command, you're telling iMacros to search for a bit of text. If the text is found, then iMacros continues, if its not found, it will throw an error. SOURCE=TXT is the equivelant of using Find within your browser to search the page for some text. you either get it, or you dont.
leegold
Posts: 8
Joined: Wed Oct 27, 2010 9:04 am

Re: Using SEARCH SOURCE=TXT

Post by leegold » Sat Jul 23, 2011 7:23 pm

I see...I'll have to try it someday I assume an error of not finding does not stop execution and it can be caught and acted upon in a script.

Thanks for help - very powerful stuff.
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Using SEARCH SOURCE=TXT

Post by MattBell7 » Mon Jul 25, 2011 9:24 am

Nope, if it doesn't find it, it'll stop the script, same as every other iMacros command. You'll need to use the scripting interface if you want a different course of action depending on the outcome.
User avatar
322126384
Posts: 32
Joined: Sat Jul 23, 2011 1:39 am

Re: Using SEARCH SOURCE=TXT

Post by 322126384 » Sun Jul 31, 2011 6:25 pm

MattBell7 wrote:Nope, if it doesn't find it, it'll stop the script, same as every other iMacros command. You'll need to use the scripting interface if you want a different course of action depending on the outcome.
Not necessarily, if you use this command, then the macro searches for the keyword and if it IS found then the program stops, but yes you will need to use the scripting interface to do a different action (like clicking on a link) if keyword is found.

Code: Select all

TAG POS=1 TYPE=* ATTR=TXT:*Keyword that you are looking for* CONTENT=EVENT:FAIL_IF_FOUND
-322126384
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Using SEARCH SOURCE=TXT

Post by MattBell7 » Sun Jul 31, 2011 10:10 pm

CONTENT=EVENT:FAIL_IF_FOUND doesn't work on input fields btw (or at least it didn't when i last used it),

but yes, you can use that to trigger a failure. Dont think you can use it with the SEARCH command though
Tom, Tech Support
Posts: 3609
Joined: Mon May 31, 2010 4:59 pm

Re: Using SEARCH SOURCE=TXT

Post by Tom, Tech Support » Tue Aug 02, 2011 10:01 pm

MattBell7 wrote:CONTENT=EVENT:FAIL_IF_FOUND doesn't work on input fields btw (or at least it didn't when i last used it),
Yes, you can use it with input fields, try the following:

Code: Select all

URL GOTO=http://www.iopus.com/imacros/demo/v6/f1/form.asp
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:Inputform ATTR=VALUE:your<SP>E-mail<SP>here CONTENT=EVENT:FAIL_IF_FOUND
Regards,

Tom, iMacros Support
Post Reply