第一次使用iMacros。
我想运行50x循环,然后完成后,单击" Next"按钮并再次运行相同的循环50x,单击"下一步" ...直到"下一步"不再可点击。
到目前为止,我只有一次工作:SET !LOOP 1
TAG POS={{!LOOP}} TYPE=TD ATTR=CLASS:domain EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=Extract_{{!NOW:ddmmyy}}.csv
'click NEXT'
TAG POS=1 TYPE=A ATTR=TXT:Next
WAIT SECONDS=3
答案 0 :(得分:3)
此代码可以帮助您,
只是让您熟悉imacros的解释。
<强>代码:强>
var macro1;
macro1 = "CODE:";
macro1 += "SET !ERRORIGNORE YES" + "\n";
macro1 += "TAG POS=1 TYPE=A ATTR=TXT:Next EXTRACT=TXT" + "\n";
var macro2;
macro2 = "CODE:" + "\n";
macro2 += "SET !ERRORIGNORE YES" + "\n";
macro2 += "TAG XPATH=(/html/body//td[contains(@class,'domain')])[{{j}}] EXTRACT=TXT" + "\n";
macro2 += "SAVEAS TYPE=EXTRACT FOLDER=C:/Users/Naren/Desktop/ FILE=output.csv" + "\n";
var macro3;
macro3 = "CODE:" + "\n";
macro3 += "SET !ERRORIGNORE YES" + "\n";
macro3 += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
macro3 += "WAIT SECONDS=5" + "\n";
for(var j = 1; j <= 50; j++){
iimSet("j",j);
iimPlay(macro2);
}
iimPlay(macro3);
do{
iimPlay(macro1);
var macro1Extract = iimGetLastExtract();
if (macro1Extract !== 'Next') {
break;
}
for(var j = 1; j <= 50; j++){
iimSet("j",j);
iimPlay(macro2);
}
iimPlay(macro3);
}while (true);