iMacro 将未找到元素的数据提取到 csv 文件

iMacro extracting data to csv file for not found elements

我有以下 iim 文件:

TAB T=1
TAB CLOSEALLOTHERS
SET !EXTRACT_TEST_POPUP NO
URL GOTO=http://example.com

SET !DATASOURCE csv_example.csv
SET !DATASOURCE_COLUMNS 2

' it will loop trought 1000 records
SET !LOOP 1

SET !DATASOURCE_LINE {{!LOOP}}
' input fields from csv file
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:ex1 ATTR=NAME:im1 CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:ex1 ATTR=NAME:im2 CONTENT={{!COL2}}
' submit form
TAG POS=1 TYPE=A FORM=NAME:ex1 ATTR=TXT:Submit

' wait while ajax request finish
WAIT SECONDS=60

' start extract to csv file

' first results
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input1 EXTRACT=TXT
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input2 EXTRACT=TXT
ADD !EXTRACT "1"

TAG POS=1 TYPE=A ATTR=ID:apple1 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:hp1 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:lg1 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:canon1 EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\iMacros FILE=Example_{{!NOW:yyyymmdd}}.csv


' second results
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input1 EXTRACT=TXT
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input2 EXTRACT=TXT

ADD !EXTRACT "2"

TAG POS=1 TYPE=A ATTR=ID:apple2 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:hp2 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:lg2 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:canon2 EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\iMacros FILE=Example_{{!NOW:yyyymmdd}}.csv

' third results
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input1 EXTRACT=TXT
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input2 EXTRACT=TXT

ADD !EXTRACT "3"

TAG POS=1 TYPE=A ATTR=ID:apple3 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:hp3 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:lg3 EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:canon3 EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\iMacros FILE=Example_{{!NOW:yyyymmdd}}.csv

但问题是,例如

TAG POS=1 TYPE=A ATTR=ID:apple3 EXTRACT=TXT

在结果页面中没有找到,它不会作为“”导出到csv文件,而是立即导出下一个元素文本

TAG POS=1 TYPE=A ATTR=ID:hp3 EXTRACT=TXT,

并且由于该行中没有 7 列,例如 6 列,我无法检查什么值是空的,因为它们以逗号分隔的形式导出。

据我所知,iMacros 不支持 if else 语句,所以我无法检查它是否为空。

尝试实现这样的想法:

'...

' third results
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input1 EXTRACT=TXT
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:input2 EXTRACT=TXT

ADD !EXTRACT "3"
SET myExtract {{!EXTRACT}}
SET !EXTRACT NULL

SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
TAG POS=1 TYPE=A ATTR=ID:apple3 EXTRACT=TXT
SET !ERRORIGNORE NO
ADD myExtract [EXTRACT]{{!EXTRACT}}
SET !EXTRACT NULL

SET !ERRORIGNORE YES
TAG POS=1 TYPE=A ATTR=ID:hp3 EXTRACT=TXT
SET !ERRORIGNORE NO
ADD myExtract [EXTRACT]{{!EXTRACT}}
SET !EXTRACT NULL 

'...

SET !EXTRACT {{myExtract}}
SAVEAS TYPE=EXTRACT FOLDER=C:\iMacros FILE=Example_{{!NOW:yyyymmdd}}.csv

或者,我建议您使用 'iMacros for Firefox' v.8.9.7(禁用自动更新)和您自己的宏。这个旧版本的工作方式与您上面描述的不同。