iMacros: user defined variables within !COLn?

2019-05-30 15:24发布

I'm looking for a possibility to let a user choose what column of his CSV input the script should use in the {{!COLn}} part.

PROMPT "Please enter CSV column:" !VAR1

SET !DATASOURCE C:\User\Desktop\Test\testsource.csv
SET !DATASOURCE_COLUMNS 100
SET !DATASOURCE_LINE {{i}}

URL GOTO=http://www.somewebsite.com
TAG POS=1 TYPE=BUTTON ATTR=TXT:123:<SP>*
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=* CONTENT={{!COLn}}
TAG POS=1 TYPE=TD ATTR=TXT:{{!COLn}} 

n in !COLn should be set to the user defined variable !VAR1. I got now clue how! Thanks for all advices.

2条回答
爷、活的狠高调
2楼-- · 2019-05-30 15:32

Not a simple answer but you can create a php website (even for free), add a NXM matrix/dataset to it and have a simple url interface www.mysite.com/index.php?loop={{!LOOP}}&col={{!VAR1}} to return the value you want

查看更多
虎瘦雄心在
3楼-- · 2019-05-30 15:53

Here is a macro that must work fine with the first 5 columns of your datasource:

PROMPT "Please enter CSV column:" !VAR1

SET !DATASOURCE C:\User\Desktop\Test\testsource.csv
SET !DATASOURCE_COLUMNS 100
SET !DATASOURCE_LINE {{i}}

SET row "'{{!COL1}}', '{{!COL2}}', '{{!COL3}}', '{{!COL4}}', '{{!COL5}}'"
SET col EVAL("var col = eval('[{{row}}]'); col[{{!VAR1}} - 1];")

URL GOTO=http://www.somewebsite.com
TAG POS=1 TYPE=BUTTON ATTR=TXT:123:<SP>*
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=* CONTENT={{col}}
TAG POS=1 TYPE=TD ATTR=TXT:{{col}}

You should manually edit the line SET row ... so that it would represent the whole row, i.e. contain all the '{{!COLn}}' separated with commas. BTW, if the number of columns is big or/and changing often, I advise to write an additional macro that will generate this string for you.

查看更多
登录 后发表回答