imacros javascript条件跳过数据提取

时间:2013-11-20 08:27:39

标签: javascript loops conditional imacros skip

一旦遇到广告,执行下面的循环就会失败。网站故意放置随机广告。是否可以使用#EANF#来处理它?不知道如何编码它。请帮忙。像这样的东西。

//if(text=="#EANF#" || text=="undefined" || text==null || text=="" )
//{
////handle the loop
//}

var jsLF="\n";
var ret=null;

var proxynovaurl; //open url
proxynovaurl  =  "CODE:";
proxynovaurl +=  "VERSION BUILD=9002379" + jsLF; 
proxynovaurl +=  "TAB T=1" + jsLF; 
proxynovaurl +=  "TAB CLOSEALLOTHERS" + jsLF; 
proxynovaurl +=  "URL GOTO=http://www.proxynova.com/proxy-server-list/anonymous-proxies/" + jsLF; 

var proxynova; //extract part #1 value
proxynova =  "CODE:";
proxynova += "VERSION BUILD=9002379" + jsLF; 
proxynova += "TAB T=1" + jsLF; 
proxynova += "TAB CLOSEALLOTHERS" + jsLF; 
proxynova += "TAG POS={{i}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;
proxynova += "SET !VAR1 {{!EXTRACT}}" + jsLF;
proxynova += "SET !EXTRACT NULL" + jsLF;
//proxynova += "SAVEAS TYPE=EXTRACT FOLDER=C:\\  FILE=ip-address.csv" + jsLF;

var proxynovamid; //use constant for part #2 value
proxynovamid =  "CODE:";
proxynovamid += "VERSION BUILD=9002379" + jsLF; 
proxynovamid += "TAB T=1" + jsLF; 
proxynovamid += "TAB CLOSEALLOTHERS" + jsLF; 
//proxynovamid += "TAG POS={{j}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;
proxynovamid += "SET !VAR2 :" + jsLF;
//proxynovamid += "SET !EXTRACT NULL" + jsLF;

var proxynova1; //extract part #3 value
proxynova1 =  "CODE:";
proxynova1 += "VERSION BUILD=9002379" + jsLF; 
proxynova1 += "TAB T=1" + jsLF; 
proxynova1 += "TAB CLOSEALLOTHERS" + jsLF; 
proxynova1 += "TAG POS={{j}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;
proxynova1 += "SET !VAR3 {{!EXTRACT}}" + jsLF;
proxynova1 += "SET !EXTRACT NULL" + jsLF;

var proxynovafinal;
proxynovafinal =  "CODE:";
proxynovafinal += "ADD !EXTRACT {{!VAR1}}" + jsLF;
proxynovafinal += "ADD !EXTRACT {{!VAR2}}" + jsLF;
proxynovafinal += "ADD !EXTRACT {{!VAR3}}" + jsLF;
proxynovafinal += "SAVEAS TYPE=EXTRACT FOLDER=C:\\  FILE=ip-address.csv" + jsLF;

iimPlay(proxynovaurl); //launch url

for(var i=1;i<=236;i=i+6) //1st loop extract 1st part of value
{
iimDisplay(i);
iimSet("i", i);
iimPlay(proxynova);
iimSet("i",i);

iimSet("j",i+1);
//for(var j=17;j<=37;j=j+5) 
//{
//iimDisplay(j);
//iimSet("j", j);
iimPlay(proxynovamid); //extract 2nd part of value
iimPlay(proxynova1);   //extract 3rd part of value
iimSet("j",i+1);
iimPlay(proxynovafinal); //write final concatinated value to file (Part1+part2+part3)
}

1 个答案:

答案 0 :(得分:2)

使用iimGetExtract http://wiki.imacros.net/iimGetExtract 在提取数据的每个代码块之后获取提取值(删除SET!EXTRACT NULL以保留数据),之后您可以根据需要使用提取的数据。 这是示例

var proxynova1; //extract part #3 value
proxynova1 =  "CODE:";
proxynova1 += "VERSION BUILD=9002379" + jsLF; 
proxynova1 += "TAB T=1" + jsLF; 
proxynova1 += "TAB CLOSEALLOTHERS" + jsLF; 
proxynova1 += "TAG POS={{j}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;
proxynova1 += "SET !VAR3 {{!EXTRACT}}" + jsLF;
var qqq = iimGetExtract();
if (qqq == '#EANF#'){ data not found flow}