imacros javascript conditional skip of data extract

廉价感情. 提交于 2019-12-13 06:13:46

问题


while executing below loop fails as soon as a advertisement is encountered. Site purposefully put random advertisement. is it possible to handle it with #EANF# not sure how to code it. please help. Something like this.

//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:


use iimGetExtract http://wiki.imacros.net/iimGetExtract to get extracted value after each block of code which extracts the data (remove SET !EXTRACT NULL to keep the data), after that you can use extracted data as you wish. here is example

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} 


来源:https://stackoverflow.com/questions/20090789/imacros-javascript-conditional-skip-of-data-extract

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!