卡在.csv文件的第一行

时间:2013-12-18 04:39:50

标签: javascript loops csv

首先,我的问题与此类似,但这个答案对我不起作用: How can i set loop iMacros by Javascript?

这是一个使用2个不同数据库.csv文件的3部分代码。第一个循环工作正常,但第二次循环没有转到.csv文件的第2行,它只是从第1行重新插入相同的信息。

我认为它在某种程度上是每次循环时重置变量,而不是上升1,它只是重复1,1,1等等。

我需要一些“循环”变量每次上升1。我已经尝试将“循环”改为“我”。

以下是代码:

var jsLF = "\n";
var i;

var macro;
macro = "CODE:";
macro +=  "SET !ERRORIGNORE YES" + "\n"; 
macro +=  "SET !ERRORCONTINUE YES" + "\n"; 
macro +=  "CMDLINE !DATASOURCE PINaccounts.csv" + "\n"; 
macro +=  "SET !DATASOURCE_COLUMNS 9" + "\n"; 
macro +=  "SET !loop 1" + "\n"; 
macro +=  "SET !DATASOURCE_LINE {{!loop}}" + "\n"; 
macro +=  "TAB T=1" + "\n"; 
macro +=  "URL GOTO=http://pinterest.com/" + "\n"; 
macro +=  "TAG POS=1 TYPE=SPAN ATTR=CLASS:profileImage&&TXT:" + "\n"; 
macro +=  "TAG POS=1 TYPE=A ATTR=TXT:Log<SP>Out" + "\n"; 
macro +=  "TAG POS=1 TYPE=A ATTR=TXT:Log<SP>in<SP>now" + "\n"; 
macro +=  "TAG POS=1 TYPE=INPUT:EMAIL FORM=NAME:NoFormName ATTR=NAME:username_or_email CONTENT={{!COL3}}" + "\n"; 
macro +=  "SET !ENCRYPTION NO" + "\n"; 
macro +=  "TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:NoFormName ATTR=NAME:password CONTENT={{!COL4}}" + "\n"; 
macro +=  "TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:Log<SP>in" + "\n"; 
macro +=  "wait seconds=2" + "\n"; 

var change;
change = "CODE:";
change +=  "CMDLINE !DATASOURCE PINfollowers.csv" + "\n"; 
change +=  "SET !DATASOURCE_COLUMNS 1" + "\n"; 
change +=  "SET !loop 1" + "\n"; 
change +=  "SET !DATASOURCE_LINE {{!loop}}" + "\n"; 
change +=  "TAB T=1" + "\n"; 
change +=  "URL GOTO={{!COL1}}" + "\n"; 

var fol;
fol = "CODE:";
fol +=  "SET !ERRORIGNORE YES" + "\n"; 
fol +=  "SET !ERRORCONTINUE YES" + "\n"; 
fol +=  "TAB T=1" + "\n"; 
fol +=  "TAG POS={{!loop}} TYPE=BUTTON ATTR=TXT:Follow" + "\n"; 
fol +=  "WAIT SECONDS=2" + "\n"; 


/* ----------------------- Login loop 6 times ------------------------------ */
for (i = 1; i <= 6; i++)
   {
   iimSet("loop", i);
   iimPlay(macro);
   iimPlay(change);


/* ----------------------- Follow loop 180 times for each Login ----------------------------- */
    for (i = 1; i <= 180; i++)
    {
     iimSet("loop", i);
     iimPlay(fol);
     }
   }

2 个答案:

答案 0 :(得分:1)

您为每个循环使用相同的计数器。

尝试将i保留为外循环,并使用j作为内循环。

for (i = 1; i <= 6; i++) {
    iimSet("loop", i);
    iimPlay(macro);
    iimPlay(change);

    for (j = 1; j <= 180; j++) {
        iimSet("loop", j);
        iimPlay(fol);
    }
}

答案 1 :(得分:0)

那么有谁知道如何将javascript变量“i”插入到iMacro脚本的中间?下面的代码不起作用。

macro +=  "SET i" + "\n"; 
macro +=  "SET !DATASOURCE_LINE {{i}}" + "\n";