date.csv like this
day,month,year
15,04,2016
22,06,2017
29,06,2017
23,06,2017
示例date.csv文件中有4行。
var accounts = 7;
for(k= 1; k<= accounts; k++){
iimDisplay("first_loop: "+ k);
var extract;
extract = "CODE:";
extract += "SET !REPLAYSPEED fast" + "\n";
extract += "SET !DATASOURCE date.csv" + "\n";
extract += "SET !DATASOURCE_LINE {{CSV}}" + "\n";
extract += "URL GOTO=http://www.tcmb.gov.tr/wps/wcm/connect/tcmb+tr/tcmb+tr" + "\n";
extract += "WAIT SECONDS=2" + "\n";
extract += "TAG POS=1 TYPE=A ATTR=TXT:ARŞİV" + "\n";
extract += "FRAME F=1" + "\n";
extract += "TAG POS=1 TYPE=SELECT FORM=NAME:doviz ATTR=NAME:gun CONTENT=%{{!COL1}}" + "\n";
extract += "TAG POS=1 TYPE=SELECT FORM=NAME:doviz ATTR=NAME:ay CONTENT=%{{!COL2}}" + "\n";
extract += "TAG POS=1 TYPE=SELECT FORM=NAME:doviz ATTR=NAME:yil CONTENT=%{{!COL3}}" + "\n";
extract += "TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:doviz ATTR=NAME:chk" + "\n";
extract += "WAIT SECONDS=2" + "\n";
iimSet("CSV", k);
iimPlay(extract);
}
帐户是一个变量设置7次,这段代码工作正常..但我需要更改循环值
你可以告诉我吗?我该如何改变&#34; account&#34;变量值作为date.csv行计数..的问候, 非常感谢你
答案 0 :(得分:0)
试试这样:
var accounts = 7;
var extract;
extract = "CODE:";
extract += "SET !REPLAYSPEED fast" + "\n";
extract += "SET !DATASOURCE date.csv" + "\n";
extract += "SET !DATASOURCE_LINE {{CSV}}" + "\n";
extract += "URL GOTO=http://www.tcmb.gov.tr/wps/wcm/connect/tcmb+tr/tcmb+tr" + "\n";
extract += "WAIT SECONDS=2" + "\n";
extract += "TAG POS=1 TYPE=A ATTR=TXT:ARŞİV" + "\n";
extract += "FRAME F=1" + "\n";
extract += "TAG POS=1 TYPE=SELECT FORM=NAME:doviz ATTR=NAME:gun CONTENT=%{{!COL1}}" + "\n";
extract += "TAG POS=1 TYPE=SELECT FORM=NAME:doviz ATTR=NAME:ay CONTENT=%{{!COL2}}" + "\n";
extract += "TAG POS=1 TYPE=SELECT FORM=NAME:doviz ATTR=NAME:yil CONTENT=%{{!COL3}}" + "\n";
extract += "TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:doviz ATTR=NAME:chk" + "\n";
extract += "WAIT SECONDS=2" + "\n";
for(k= 1; k<= accounts; k++){
iimDisplay("first_loop: "+ k);
iimSet("CSV", k);
iimPlay(extract);
}
宏代码应该都在循环之外,参见?
此外,您不需要var accounts = 7;
变量集。您可以直接使用for(k= 1; k<=7; k++)
启动循环。
最后一条建议,如果你不介意:不要在这里发布实时网站的链接。
编辑: 添加了有关如何计算csv中行数的iMacros论坛的链接: http://forum.imacros.net/viewtopic.php?f=11&t=13610&p=40923&hilit=count+number+rows+csv#p40964