Pergunta

I'm trying to make an Imacros that contains 2 loops, but I can't seem to figure it out. It should first extract data from a csv file and submit it x times to mywebsite, then extract x URLs from another csv file and click y number of times on a link. I can't find any method to have to loops without using javascript, and I can't use that since I have absolutely zero knowledge about it. This is what I got so far:

TAB T=1
URL GOTO=https://mywebsite.com
SET !DATASOURCE infos.csv
SET !DATASOURCE_COLUMNS 5
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
TAG POS=1 TYPE=INPUT:Name FORM=ID:sm ATTR=ID:sl CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:age FORM=ID:iD ATTR=ID:sD CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:heigh FORM=ID:sf ATTR=ID:lf CONTENT={{!COL3}}
TAG POS=1 TYPE=INPUT:nationality FORM=ID:sfw ATTR=ID:sfq CONTENT={{!COL4}}
TAG POS=1 TYPE=SPAN ATTR=TXT:send
URL GOTO=https://www.mywebsite.com/{{!COL5}}
WAIT SECONDS=1
TAG POS={{!LOOP}} TYPE=I ATTR=TXT:Jump <-- This is the 2nd loop  -->

as an exemple, when I set the imacros play loop to 10, that should be assigned to the 1st loop.

Thanks in advance

Foi útil?

Solução

Try this maybe:

for (var i = 0; i < 10; i++)
{
    var macro = "CODE";
    macro +="URL GOTO=https://mywebsite.com" + "\n";
    macro +="SET !DATASOURCE infos.csv" + "\n";
    macro +="SET !DATASOURCE_COLUMNS 5"" + "\n";
    macro +="SET !LOOP 2" "\n";
    macro +="SET !DATASOURCE_LINE" + i + "\n";
    ....

    iimPlay(macro);
    for (var j = 0; i < 10; j++)
    {
        var macro2 = "CODE";
        macro2 += "TAG POS=" + j + "TYPE=I ATTR=TXT:Jump";
        iimPlay(macro2);
    }        
}

So basically you define a macro string and then use iimPlay() method to play it. Make sure you create a Javascript file and run it (press only Play button no Play Loop).

Every string should have "CODE:" in it to start off. Then adding a new line after every line of iMacros code.

Pretty much for the {{LOOP}} just change it to the loop variable.

Outras dicas

you can't do that with regular imacros as it does not support loop inside loop or 2 different loops inside one script. use javascript or similar.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top