iMacro JavaScript提取值

时间:2014-07-22 23:23:16

标签: javascript extract imacros

嘿伙计们我正在尝试使用iMacros在javascript中创建对象,我想最简单的方法就是告诉我你想得到它。

var load;
load = "CODE:";
load += "SET !DATASOURCE pinterestAccounts.csv" + "\n";
load += "SET !DATASOURCE_COLUMNS 4" + "\n";
load += "SET !LOOP 1" + "\n";
load += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n"; 


var accounts = new Array();
for(i=0; i<5; i++){
    iimPlay(load);
    accounts[i] = new Account("{{!COL1}}","{{!COL2}}","{{!COL3}}","{{!COL4}}");
}

所以我有一个类帐户,它接受4个参数,我试图从csv中提取它们,但我找不到放在提取命令的位置。我看到了一个获得最后一个值的示例,但我现在想要4个值,之后是5个。

认为您可以告诉我如何使用javascript提取多个值?

1 个答案:

答案 0 :(得分:5)

我解决了自己的问题

var load;
load = "CODE:";
load += "SET !DATASOURCE pinterestAccounts.csv" + "\n";
load += "SET !DATASOURCE_COLUMNS 4" + "\n";
load += "SET !LOOP "+ "{{index}}" + "\n";
load += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n"; 
load += "ADD !EXTRACT {{!COL1}}" + "\n";
load += "ADD !EXTRACT {{!COL2}}" + "\n";
load += "ADD !EXTRACT {{!COL3}}" + "\n";
load += "ADD !EXTRACT {{!COL4}}" + "\n";

var accounts = new Array();
for(i=1; i<=5; i++){ 
    iimSet("index",i);
    iimPlay(load);
    var un = iimGetLastExtract(1);
    var e = iimGetLastExtract(2);
    var pw = iimGetLastExtract(3);
    var pr = iimGetLastExtract(4);
    accounts[i] = new Account(e,un,pw,pr);
}