我做了一切处理。但没有运气它返回“未定义”的数据。我尝试了许多不同的方法来从这个网站获取数据。不成功。我在其他论坛上发布了这个,没有人能够解决这个问题来处理完整的数据提取。
我需要保存这样的数据91.228.53.28:8089每行所有行。
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)
}
答案 0 :(得分:2)
您不会将变量存储在任何位置。使用iimPlay()
擦除每个变量,就像重新开始一样,所以你的最终宏,写入文件的宏不知道!VAR1, !VAR2
等等。你应该这样做:
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)
}
改进我提供给你的这段代码,请不要再问2次同样的问题:)并且在你放SET !EXTRACT NULL
的时候一定要小心(当你需要javascript中的值时永远不会结束)< / p>
答案 1 :(得分:1)
在本文中:http://tubes.io/blog/2013/08/28/web-scraping-javascript-heavy-website-keeping-things-simple/ 它讨论了使用大量客户端渲染来提取数据。如果这没有帮助我认为它可能会导致你想要你失踪。我无法通过公司过滤器查看您的网站...... :(