is this possible in imacros javascript ? tried man

2019-05-26 19:50发布

问题:

i did everything handled. but no luck it is returning "undefined" data. i tried many differnt ways to get data from this site. not successful. I posted this in other forums no one able to solve this to handle full data extract.

i need data saved like this 91.228.53.28:8089 one per line all rows.

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 += "SET !VAR1 {{!EXTRACT}}" + jsLF;
p2 += "TAG POS={{i}} TYPE=TD ATTR=* EXTRACT=TXT" + jsLF;
p2 += "SET !EXTRACT NULL" + jsLF;

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

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

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

//ADD !VAR1 {{!EXTRACT}} // append! may be this is correct

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);

ret_val = 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);   //extract 3rd part of value
iimSet("j",i+1);
ret3 = iimPlay(p5final); //write final concatinated value to file (Part1+part2+part3)
}

回答1:

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)



回答2:

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... :(