The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
Difference between revisions of "SEARCH"
Line 36: | Line 36: | ||
Another example: Search for a script. '''Escape " with \"''' | Another example: Search for a script. '''Escape " with \"''' | ||
SEARCH SOURCE=TXT:"<script src=\"/js/datevalidator.js\"" | SEARCH SOURCE=TXT:"<script src=\"/js/datevalidator.js\"" | ||
+ | |||
+ | See also: Detect errors of a script with [[ONERROR]] CONTINUE=NO |
Revision as of 16:53, 20 February 2010
Currently this command is available in iMacros for Firefox. It will be soon available in other iMacros versions, too.
The SEARCH commands works with page source, instead of looking at the web page object model (DOM) that the TAG command uses. Thus SEARCH also "sees" e. g. comments in the page source code.
Syntax
SEARCH SOURCE=(TXT|REGEX) IGNORE_CASE=YES EXTRACT=$1
Notes:
- The default is IGNORE_CASE=NO
- Extracted information is always of type text, as the SEARCH command works on the page source code. $1 refers to the Regular Expressions syntax. So the use of EXTRACT requires the use of the REGEX attribute.
- The REGEX attribute works with standard Regular Expressions (often called regex or regexp).
Examples
Test macro: This macro checks for the presence of the Google Analytics script on our website and then extracts the ID of it.
URL GOTO=http://iopus.com/ 'Check for Script SEARCH SOURCE=TXT:"_gat._getTracker(\"UA-336765-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}}
Note: REGEXP:"_get[Tt]racker\\(([^)]+)\\)" means:
- find the word _get[Tt]racker, with T or t
- \\( - opening brace followed by anything except closing brace
- [^)] repeated one or more times and ending with closing brace \\)
- => anything but not a closing brace is surrounded by capturing braces - ()
- => it extracts the argument of the gettracker command, that is the text between (...)
- The result is saved in $1, which is then assigned to the !EXTRACT variable
Another example: Search for a script. Escape " with \"
SEARCH SOURCE=TXT:"<script src=\"/js/datevalidator.js\""
See also: Detect errors of a script with ONERROR CONTINUE=NO