我有以下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语句,所以我无法检查它是否为空。
答案 0 :(得分:2)
尝试实现这样的想法:
'...
' 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
或者,我建议您使用适用于Firefox的iMacros' v.8.9.7(具有禁用的自动更新)和您自己的宏。这个旧版本的工作方式与您上面描述的不同。