is this possible in imacros javascript ? tried many ways not successful

偶尔善良 提交于 2019-12-06 08:17:35

you don't store your variables anywhere. using iimPlay() erases every variable, is like starting over, so your final macro, the one that writes to the file doesn't know about !VAR1, !VAR2 etc. You should do something like this:

var jsLF="\n";
var ret,ret1,ret2,ret3,ret_val;


var p1; //open url
p1  =  "CODE:";
p1 +=  "URL GOTO=http://www.proxynova.com/proxy-server-list/country-de/" + jsLF;

var p2; //extract 1st value ip save to tmp VAR1
p2  =  "CODE:";
p2 += "TAG POS={{i}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;

var p3; //add constant value =":" Save to tmp VAR2
p3  =  "CODE:";
p3 += "SET !VAR2 :" + jsLF;


var p4; //extract port number
p4  =  "CODE:";
p4 += "TAG POS={{j}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;


var p5final; //mer 3 parts to get final and save
p5final =  "CODE:";
p5final += "ADD !EXTRACT {{myvar1}}" + jsLF;
p5final += "ADD !EXTRACT :" + jsLF;
p5final += "ADD !EXTRACT {{myvar2}}" + jsLF;
p5final += "SAVEAS TYPE=EXTRACT FOLDER=C:\\  FILE=ip-address.csv" + jsLF;

ret = iimPlay(p1);
for(var i=1;i<=20;i=i+6) //1st loop extract 1st part of value
{
     iimSet("i", i);
     iimPlay(p2);
     iimSet("i",i);

     myvar1 = iimGetExtract();
     if(ret_val=="#EANF#" || ret_val=="undefined" || ret_val==null || ret_val=="" )
     {
         iimSet("i",i+1);
     }

     ret1=iimPlay(p3); //extract 2nd part of value
     iimSet("j",i+1);
     ret2 = iimPlay(p4);
     myvar2 = iimGetExtract();   //extract 3rd part of value
     iimSet("myvar1",myvar1);
     iimSet("myvar2",myvar2);
     ret3 = iimPlay(p5final); //write final concatinated value to file (Part1+part2+part3)
     }

Improve on this code I provided you and please don't ask the same question 2 times :) and always be careful where you put the SET !EXTRACT NULL (never on the end when you need the value in javascript)

In this article: http://tubes.io/blog/2013/08/28/web-scraping-javascript-heavy-website-keeping-things-simple/ It talks about extracting data with a lot of client side rendering. If this doesn't help I think it might lead you to want you're missing. I can't view your site through the corporate filter... :(

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