imacros javascript 不会循环遍历 csv
imacros javascript wont loop through csv
我刚刚在 Javascript 中编写了一个宏脚本。该代码在 imacros 中运行良好,但当通过 javascript 运行 时循环不会递增。以下代码继续使用数据源 csv 文件的第一行。
macro += "VERSION BUILD=9002379" + "\n";
macro += "TAB T=1" + "\n";
macro += "TAB CLOSEALLOTHERS" + "\n";
macro += "SET !DATASOURCE C:\imacros\demo.csv" + "\n";
macro += "" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "URL GOTO={{!COL2}}" + "\n";
macro += "WAIT SECONDS=1" + "\n";
macro += "ADD !EXTRACT {{!COL1}}" + "\n";
macro += "" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:deguy EXTRACT=TXT" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=ID:idvenga EXTRACT=TXT" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=C:\imacros FILE=results.csv" + "\n";
var n = 10;
for (i=1;i<=n;i++){
iimPlay(macro);
}
如何让它遍历数据源 csv 文件的所有行。
这是必须控制循环变量的方法
macro += "VERSION BUILD=9002379" + "\n";
macro += "TAB T=1" + "\n";
macro += "TAB CLOSEALLOTHERS" + "\n";
macro += "SET !DATASOURCE C:\imacros\demo.csv" + "\n";
macro += "" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "SET !DATASOURCE_LINE {{i}}" + "\n";
macro += "URL GOTO={{!COL2}}" + "\n";
macro += "WAIT SECONDS=1" + "\n";
macro += "ADD !EXTRACT {{!COL1}}" + "\n";
macro += "" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:deguy EXTRACT=TXT" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=ID:idvenga EXTRACT=TXT" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=C:\imacros FILE=results.csv" + "\n";
for (var i=1;i<10;i++)
{
iimSet("i",i)
iimPlay(macro)
}
我刚刚在 Javascript 中编写了一个宏脚本。该代码在 imacros 中运行良好,但当通过 javascript 运行 时循环不会递增。以下代码继续使用数据源 csv 文件的第一行。
macro += "VERSION BUILD=9002379" + "\n";
macro += "TAB T=1" + "\n";
macro += "TAB CLOSEALLOTHERS" + "\n";
macro += "SET !DATASOURCE C:\imacros\demo.csv" + "\n";
macro += "" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "URL GOTO={{!COL2}}" + "\n";
macro += "WAIT SECONDS=1" + "\n";
macro += "ADD !EXTRACT {{!COL1}}" + "\n";
macro += "" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:deguy EXTRACT=TXT" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=ID:idvenga EXTRACT=TXT" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=C:\imacros FILE=results.csv" + "\n";
var n = 10;
for (i=1;i<=n;i++){
iimPlay(macro);
}
如何让它遍历数据源 csv 文件的所有行。
这是必须控制循环变量的方法
macro += "VERSION BUILD=9002379" + "\n";
macro += "TAB T=1" + "\n";
macro += "TAB CLOSEALLOTHERS" + "\n";
macro += "SET !DATASOURCE C:\imacros\demo.csv" + "\n";
macro += "" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "SET !DATASOURCE_LINE {{i}}" + "\n";
macro += "URL GOTO={{!COL2}}" + "\n";
macro += "WAIT SECONDS=1" + "\n";
macro += "ADD !EXTRACT {{!COL1}}" + "\n";
macro += "" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:deguy EXTRACT=TXT" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=ID:idvenga EXTRACT=TXT" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=C:\imacros FILE=results.csv" + "\n";
for (var i=1;i<10;i++)
{
iimSet("i",i)
iimPlay(macro)
}