imacros javascript return top

泪湿孤枕 提交于 2019-12-12 02:48:37

问题


I'm writing a imacros script using javascript and I've a problem.

var result = "";
var Loop = 1;
while(true)
{    

iimSet("Loop",Loop);
var macro;
    macro="CODE:";
    macro +="SET !DATASOURCE site.csv" + "\n";
    macro +="SET !DATASOURCE_LINE {{Loop}}" + "\n";
    macro +="URL GOTO=https://www.google.com/search?q={{!COL1}}" + "\n";  
    macro +="WAIT SECONDS=1" + "\n";          
iimPlay(macro);

var ret_code = iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=ID:resultStats");
    if(ret_code<0){break;}
ret_code = iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=ID:resultStats EXTRACT=TXT");
    s = iimGetLastExtract();    
    result += " "+s;    
    Loop++
}
var Ru;
    Ru="CODE:";

iimPlay("#current.iim"); 

Here's the process. It loop throught the csv file and checks for how many pages are indexed in google results. Sometimes google asks to enter captcha. If captcha appears it breaks from 'var macro' and goes to 'var ru' which is for captcha part. After entering the captcha I need to return to 'var macro' and continue from where it left. And also I need to set a loop to datasource to stop everything. Can't seem to figure this out. Looking for your help.

Thank you, Mark.


回答1:


So, you may try something like this:

for the 1st issue:

// ...
var ret_code = iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=ID:resultStats");
if (ret_code < 0)
    iimPlay("#current.iim");
iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=ID:resultStats");
ret_code = iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=ID:resultStats EXTRACT=TXT");
// ...

for the 2nd issue:

// ...
    macro +="WAIT SECONDS=1" + "\n";          
var ret_code = iimPlay(macro);
if (ret_code < 0)
    break;
// ...


来源:https://stackoverflow.com/questions/32808396/imacros-javascript-return-top

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