You can use the EXTRACT command and make the keyword the extraction anchor. The general idea is to try and extract a certain piece of information and then check if the extraction result is the Extraction Anchor Not Found (#EANF#) message.
Example: We want to find out if the words "Order completed" are displayed on a web page. If yes, we want to print the page. To search the web page for the test phrase, create a macro called mysearch, which only has two lines:
VERSION BUILD=4210125
EXTRACT POS=1 TYPE=TXT ATTR=*Order<SP>completed*
In this example, we are searching the web page for the first occurrence (POS=1) of the keyword "Order completed". If the message #EANF# is returned, then the keyword was not found as the keyword is the data extraction anchor. If the keyword was found, the EXTRACT command returns the complete text of the found HTML tag. In our example, this could be "Software Order completed".
To print the web page, create a macro called print_this. It has only two lines:
VERSION BUILD=4210125
PRINT
To connect both macros together, create a small Windows script:
'test if keyword appeared on website.
If iplay = 1 Then
If instr (extracted_text, "#EANF#") > 0 Then
MsgBox ("Sorry, keywords not found")
Else
iplay = iim1.iimPlay("print_this")
End If
End If
If iplay < 0 Then
MsgBox "Error!"
End If
Note: The same procedure can be used to look for several keywords on a page, for example "cat", "dog" and "mouse":
The solution is to use several EXTRACT commands. So in the macro use:
In the script, you can look at each array element to see if they keyword was found:
iplay = iim1.iimPlay("wsh-extract-rate")
data = iim1.iimGetLastExtract()
If iplay = 1 Then
data= Split(data, "[EXTRACT]")
If data(1) <> "#EANF#" Then MsgBox "Keyword CAT found!"
If data(2) <> "#EANF#" Then MsgBox "Keyword DOG found!"
If data(3) <> "#EANF#" Then MsgBox "Keyword MOUSE found!"
End If