iMacros - Loop - Help with Javascript

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

iMacros - Loop - Help with Javascript

by bjm778 on Wed Sep 21, 2016 4:42 am

Can someone help me with this. I have csv file which will have 3 columns ideally.
Column 1 - Website link to load, Column 2 - number of times consequent page scroll or Next button to be clicked for that particular page alone and Column 3 is going to number of Products for which Hyperlinks needs to be extracted.

Now the problem I have is to build a script to Run 3 steps sequentially and Step 2 and Step 3 alone will have Loops defined based on the value detailed in CSV columns 2 and 3.

Step 1 - Load the website 1 listed in Col1 of the CSV
Step 2 - Take the custom value for fetch / scrol / next page numbers to be clicked
Step 3 - Once all the next pages and fetches are loaded and ready for extraction. Take the custom value from Col 3 in CSV for the number of products / listings for which links needs to be extracted.

Code below,

var macro = "CODE1:";
macro += "VERSION BUILD=10022823" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_PAGE 1" + "\n";
macro += "SET !REPLAYSPEED FAST" + "\n";
macro += "SET !DATASOURCE C:\\dummy\\Links.csv" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "URL GOTO={{!COL1}}" + "\n";
macro += "TAB T=1" + "\n";
macro += "TAB CLOSEALLOTHERS" + "\n";


var macro = "CODE2:";
var m;
macro += "SET !DATASOURCE C:\\dummy\\Links.csv" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "URL GOTO=javascript:window.scrollBy(0,20000)" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=ID:fetch{{i}}" + "\n";
macro += "TAG POS=1 TYPE=DIV ATTR=ID:scroll{{i}}" + "\n";
macro += "WAIT SECONDS=0.2" + "\n";
macro += "m={{!COL2}}" + "\n";
for(var i=0;i<m;i++)
{
iimSet("m",i)
iimPlay(macro);
}
iimDisplay("ScriptCompleted")


var macro = "CODE3:";
var p;
macro += "VERSION BUILD=10022823" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !REPLAYSPEED FAST" + "\n";
macro += "SET !DATASOURCE C:\\dummy\\Links.csv" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "SET !DATASOURCE_COLUMNS 3" + "\n";
macro += "WAIT SECONDS=0.01" + "\n";
macro += "WAIT SECONDS=0.01" + "\n";
macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=CLASS:lcname* EXTRACT=htm" + "\n";
macro += "TAG POS={{i}} TYPE=SPAN ATTR=CLASS:lcname* EXTRACT=TXT" + "\n";
macro += "SAVEAS TYPE=EXTRACT FOLDER=c:\dummy FILE=IM_Profile_Pages.csv" + "\n";
macro += "p={{!COL3}}" + "\n";
for(var i=0;i<p;i++)
{
iimSet("p",i)
iimPlay(macro);
}
iimDisplay("ScriptCompleted")
bjm778
 
Posts: 1
Joined: Thu Mar 24, 2016 1:51 am

Return to General Support & Discussions

Who is online

Users browsing this forum: Google [Bot] and 6 guests

-->