我有一个imacros脚本从csv文件中获取数据。但我需要告诉imacros从列中随机获取数据。即:
=ID:tag_editor_input CONTENT={{!COL2}}
=ID:tag_editor_input CONTENT={{!COL2}}
=ID:tag_editor_input CONTENT={{!COL2}}
=ID:tag_editor_input CONTENT={{!COL2}}
=ID:tag_editor_input CONTENT={{!COL2}}
第2列中的我存储了很多值,但我需要为每一行提供与COL2不同的值。 有可能吗?
回复Bestmacros。
Thx Bestmacros但我想我仍然做错了因为它不起作用。所以这是脚本:
SET !VAR0 901
ADD !VAR0 {{!LOOP}}
SET !DATASOURCE_DELIMITER ;
SET !DATASOURCE file.csv
SET !LOOP 1
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:post_three CONTENT=http://www.{{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
TAG POS=1 TYPE=TEXTAREA FORM=NAME:source ATTR=ID:htmlSource CONTENT={{!VAR0}} <a<SP>href="http://www.{{!COL3}}"<SP>target="_blank">www.{{!COL4}}</a>
如您所见,我需要5个标签中col2的随机值。其他列必须只有一个值。 考虑到整个脚本必须重复多次(循环)并且每次VAR0必须增加1,我在哪里插入代码?
答案 0 :(得分:4)
是的,这是可能的 - 这里是从前10行(从第2列)获取随机数据的示例
SET !VAR0 901
ADD !VAR0 {{!LOOP}}
SET !DATASOURCE_DELIMITER ;
SET !DATASOURCE file.csv
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:post_three CONTENT=http://www.{{!COL1}}
SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*10 + 1); randomNumber;")
SET !DATASOURCE_LINE {{!VAR1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*10 + 1); randomNumber;")
SET !DATASOURCE_LINE {{!VAR1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*10 + 1); randomNumber;")
SET !DATASOURCE_LINE {{!VAR1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*10 + 1); randomNumber;")
SET !DATASOURCE_LINE {{!VAR1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:tag_editor_input CONTENT={{!COL2}}
SET !DATASOURCE_LINE {{!LOOP}}