1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

iMacros - Loop - Help with Javascript

Discussion in 'Black Hat SEO Tools' started by bjm778, Sep 20, 2016.

  1. bjm778

    bjm778 Newbie

    Joined:
    Sep 20, 2016
    Messages:
    1
    Likes Received:
    0
    Gender:
    Male
    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")