Loop Datasource

Discussions and Tech Support specific to the iMacros Firefox Add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Loop Datasource

Post by JohnnyMaus0912 » Thu Sep 07, 2017 3:40 pm

Hello everybody!

Sorry for my bad english, I'm from Germany and need some help with "iMacros".

I have created a database ("Datasource") with 5 different words.
The script should gradually enter each word and then start over again, this does not work.

Here is my script:
Does somebody has any idea?

Code: Select all

SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*15 + 1); randomNumber;")
SET !VAR2 EVAL("var randomNumber=Math.floor(Math.random()*10 + 1); randomNumber;")
SET !VAR3 EVAL("var randomNumber=Math.floor(Math.random()*40 + 1); randomNumber;")
SET !VAR4 EVAL("var randomNumber=Math.floor(Math.random()*20 + 8); randomNumber;")
SET !TIMEOUT_PAGE 1
SET !ERRORIGNORE YES
SET !DATASOURCE word.csv
SET !DATASOURCE_LINE {{!LOOP}} 
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
set var5 {{!COL1}}
WAIT SECONDS={{!var4}}
URL GOTO=https:.........................{{var5}}
WAIT SECONDS={{!var4}}
TAG POS=1 TYPE=DIV ATTR=CLASS:................
WAIT SECONDS={{!var3}}


JohnnyMaus
techimac
Posts: 309
Joined: Fri Feb 20, 2015 9:27 pm

Re: Loop Datasource

Post by techimac » Thu Sep 07, 2017 7:58 pm

run this in loop of 5

Code: Select all

SET !TIMEOUT_PAGE 60
SET !ERRORIGNORE YES
SET !DATASOURCE word.csv
SET !DATASOURCE_COLUMNS 1

SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*15 + 1); randomNumber;")
SET !VAR2 EVAL("var randomNumber=Math.floor(Math.random()*10 + 1); randomNumber;")
SET !VAR3 EVAL("var randomNumber=Math.floor(Math.random()*40 + 1); randomNumber;")
SET !VAR4 EVAL("var randomNumber=Math.floor(Math.random()*20 + 8); randomNumber;")

WAIT SECONDS={{!var1}}
URL GOTO=https:.........................{{!COL1}}
WAIT SECONDS={{!var2}}
TAG POS=1 TYPE=DIV ATTR=CLASS:................
WAIT SECONDS={{!var3}}
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Re: Loop Datasource

Post by JohnnyMaus0912 » Fri Sep 08, 2017 2:24 pm

Still does not work. As soon as "iMacros" is entered from the database at the last word, it still does not start with the first one.
That means I need a loop, that he always starts the database from the beginning, once it has gone through.
techimac
Posts: 309
Joined: Fri Feb 20, 2015 9:27 pm

Re: Loop Datasource

Post by techimac » Fri Sep 08, 2017 3:48 pm

JohnnyMaus0912 wrote:Still does not work. As soon as "iMacros" is entered from the database at the last word, it still does not start with the first one.
That means I need a loop, that he always starts the database from the beginning, once it has gone through.
you need javascript to loop again and again from beginning of datasource file
or simply repeat entries in csv file.
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Re: Loop Datasource

Post by JohnnyMaus0912 » Fri Sep 08, 2017 5:50 pm

Okay, thanks for this reply. Have no idea of Java, maybe you had a small script for me or is that very difficult?
techimac
Posts: 309
Joined: Fri Feb 20, 2015 9:27 pm

Re: Loop Datasource

Post by techimac » Fri Sep 08, 2017 8:21 pm

Code: Select all

var Macro = "";
Macro += "CODE:" + "\n";
Macro += "SET !ERRORIGNORE YES" + "\n";
Macro += "SET !DATASOURCE word.csv" + "\n";
Macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
Macro += "SET !DATASOURCE_LINE {{LOOPNUM}}" + "\n";
Macro += "SET !TIMEOUT_PAGE 60" + "\n";
Macro += "SET !VAR1 EVAL(\"1 + Math.floor(Math.random()*15)\")" + "\n";
Macro += "SET !VAR2 EVAL(\"1 + Math.floor(Math.random()*10)\")" + "\n";
Macro += "SET !VAR3 EVAL(\"1 + Math.floor(Math.random()*40)\")" + "\n";
Macro += "SET !VAR4 EVAL(\"8 + Math.floor(Math.random()*20)\")" + "\n";
Macro += "WAIT SECONDS={{!VAR1}}" + "\n";
Macro += "URL GOTO=https:.........................{{!COL1}}" + "\n";
Macro += "WAIT SECONDS={{!VAR2}}" + "\n";
Macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:................" + "\n";
Macro += "WAIT SECONDS={{!VAR3}}" + "\n";

for(var x=1;x>0;x++)
{

for(var loop=1;loop<6;loop++)
{
        iimSet("LOOPNUM",loop)
        iimPlay(Macro);
}

}

file extension will be "js".
so save as filename.js
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Re: Loop Datasource

Post by JohnnyMaus0912 » Sat Sep 09, 2017 5:04 pm

Have now a file under "Macros" created with this code and it ending with the ending "js".
It does not work. Would be nice if you could help me. It sprint only in the last lines, if I want to start it under "Firefox".

For example, there are two words in the Datasource file: "test1" and "test2".
Now he should first open the page with the suffix "test1" and in the next run "test2". Then he should start again with "test1".
techimac
Posts: 309
Joined: Fri Feb 20, 2015 9:27 pm

Re: Loop Datasource

Post by techimac » Sat Sep 09, 2017 7:05 pm

for(var loop=1;loop<6;loop++)

here replace 6 with no of rows in csv file + 1
chivracq
Posts: 8980
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Loop Datasource

Post by chivracq » Sat Sep 09, 2017 7:09 pm

Pfff, mixed Feeling about this Thread, I didn't react because "CIM" (meant for you @OP who couldn't read the Forum Rules for Required Info to include in your OP when you open a Thread...! :roll: ), then OK, I followed a bit, and hum, Script from @OP is probably meant to kind of spam other poor Users on some Forum or Social Media Site, which I don't support anyway and consider myself as complete SPAM...! :shock:

But hum..., at @techimac, you are making "Things" very complicated, no need to use a '.js' Script, @OP thinks it's "Java" anyway and won't understand anything from it... Try to keep it simple, I would think... :idea:
And you shouldn't be helping Users who want to use/misuse iMacros for spamming other People, but I think I already had the "Clash" about that with you, I won't try to help anymore when you have some real Pb on your own... :twisted:

You are a fairly Advanced User, probably more Advanced than me on '.js' Scripts (that I never used anyway, ah-ah...!), try to help Users with some "Legit" Use for iMacros, not "Script-Kiddies" trying to spam other Users... The more that kind of Users use/misuse iMacros for their Goal, the more difficult it becomes (for us) to use iMacros for Legit Web-Automation, if you are a bit clever... :roll: :idea:

(And yep, of course it's an "easy" Thread, could have been "solved" with 1 Post...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Re: Loop Datasource

Post by JohnnyMaus0912 » Sun Sep 10, 2017 2:01 pm

Stop! This is not about spamming. I need this script for my Shishabar for the TV. I will display my own website with different images etc. during the opening hours.
chivracq
Posts: 8980
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Loop Datasource

Post by chivracq » Sun Sep 10, 2017 3:35 pm

JohnnyMaus0912 wrote:Stop! This is not about spamming. I need this script for my Shishabar for the TV. I will display my own website with different images etc. during the opening hours.
Hum, OK, then if your Purpose is "Legit", there was not need to obfuscate your Script to make it so "anonymous" and unrecognizable...
Scripts with Random 'WAIT' Statements are usually meant to avoid Detection and always look a bit "suspicious" to me, ah-ah...!

Hum, and you missed the "CIM" part from my previous Post, but OK, never mind... And good luck further with @techimac then...

But as I said, there is no Need to use a '.js' Script in this Case (oh...!, that means you are on FF then), that only makes "Things" more complicated in my Opinion, you simply need a "Nested Loop" (many Threads about that on the Forum) or you simply repeat 5 Blocks for your 5 Keywords and you increment '!DATASOURCE_LINE' for each Block... There is no Difficulty...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Re: Loop Datasource

Post by JohnnyMaus0912 » Mon Sep 11, 2017 5:52 pm

I'm sorry if you misunderstood. The changing wait time is only there to try out something and bring some change.
The times are also changed or completely changed in fixed times. But I do not know yet.
I keep the whole relatively anonymous, because customers should not see this and the homepage is not yet 100 percent finished.
I also do not want to advertise. :-)

Would it be possible that you write me an example script, how would you do this without JavaScript?
techimac
Posts: 309
Joined: Fri Feb 20, 2015 9:27 pm

Re: Loop Datasource

Post by techimac » Mon Sep 11, 2017 6:17 pm

without javascript you will have to add/delete repetitive code
if number of keywords are changing in csv

I gave you working code, use it.
JohnnyMaus0912
Posts: 12
Joined: Thu Sep 07, 2017 3:29 pm

Re: Loop Datasource

Post by JohnnyMaus0912 » Tue Sep 12, 2017 2:22 pm

All right, I'll try right out. But what do you mean by +1?
If I have 4 lines, then I write:

Code: Select all

for (var loop = 1; loop <4; loop ++)
EDIT: Is it also possible to have two datasource in a macro?

Because my intention is that he opens certain areas from my homepage and then opens certain files there. Do you know what I mean?
techimac
Posts: 309
Joined: Fri Feb 20, 2015 9:27 pm

Re: Loop Datasource

Post by techimac » Tue Sep 12, 2017 6:08 pm

It is possible.
Post Reply