我有一个从csv文件中获取数据的imacros脚本。但是我需要告诉 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 中获取不同的值。可能吗?
回复最佳宏。
谢谢最好的宏,但我想我仍然做错了什么,因为它不起作用。所以这是脚本:
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,我在哪里插入您的代码?
是的,这是可能的 - 这是从前 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}}