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

[WTH] Imacros/javascript expert to create a Simple Script.

Discussion in 'Hire a Freelancer' started by ChapoGuzman, Jan 12, 2014.

  1. ChapoGuzman

    ChapoGuzman BANNED BANNED

    Joined:
    Jun 7, 2013
    Messages:
    294
    Likes Received:
    187
    Okay I need the script to loop/replay X amount of time and ever replay/loop to cycle through a csv and check if the link exist on a page if it doesnt stop and move on to the next loop (column) in the csv, but if the link does exist to just keep running the macros as normal.

    here the script I came up with but you cant do it in imacros has to be ran from javascript

    Code:
    VERSION BUILD=8601111 RECORDER=FXSET 
    !DATASOURCE check.csv
    SET !LOOP 1
    SET !DATASOURCE_COLUMNS 2
    set !var1 1
    add !var1 {{!loop}}
    SET !DATASOURCE_LINE {{!var1}}
    
    TAB T=1
    URL GOTO=http://{{!COL1}}.blogspot.com/
    TAG POS=2 TYPE=A ATTR=HREF:http://{{!COL2}}.blogspot.com/
    'if the link above does not exist stop macros and move on to next loop, but if link above does exist executing macros.
    URL GOTO=http://google.com/
    ADD !EXTRACT {{!COL2}}
    SAVEAS TYPE=EXTRACT FOLDER=c:\iMacros FILE=table.csv
    
    Reason this cant be done in regular macros is because macros doesnt allow conditional statement.

    so I believe something like this will work

    Code:
    VERSION BUILD=8601111 RECORDER=FXSET 
    !DATASOURCE check.csv
    SET !LOOP 1
    SET !DATASOURCE_COLUMNS 2
    set !var1 1
    add !var1 {{!loop}}
    SET !DATASOURCE_LINE {{!var1}}
    
    TAB T=1
    URL GOTO=http://{{!COL1}}.blogspot.com/
    if { 
    // link below exist
       TAG POS=2 TYPE=A ATTR=HREF:http://{{!COL2}}.blogspot.com/
       URL GOTO=http://google.com/
      ADD !EXTRACT {{!COL2}}
     SAVEAS TYPE=EXTRACT FOLDER=c:\iMacros FILE=table.csv
    } 
    Else {
          restart Macros to cycle the next loop in csv.
    };}
    


    LOL that shows you how I know how it should work but I just aint on that level yet to do it.

    I tried asking on stackoverflow but they just assume I want someone to do it for me and brushed me off which wasnt the case I was trying to learn it but it is what it is. I came to the point that this is taking to much of my time then it is worth so Im willing to pay. I can only pay $5 bucks yea I know wish I can offer more but thats all I have in paypal at the moment, but Im always doing lil work like this so im sure I will come back to your for future help/work.

    anyone interested please let me know.
     
    Last edited: Jan 12, 2014
  2. BotCoder

    BotCoder Junior Member

    Joined:
    Jan 12, 2014
    Messages:
    119
    Likes Received:
    328
    Brother I hate to break it to you but imacros is very limited and does not offer logic. Meaning no if then statements. Vb net is very easy for people who are new to programming. Or you could look into python. Teach your self to program and you will be much happier. Imacros, while being useful, is just not able to perform tasks that involve logic. Well good luck op!
     
    • Thanks Thanks x 1
  3. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    950
    Likes Received:
    662
    Occupation:
    Web/Bot Developer
    Just sent you a pm.
     
  4. ChapoGuzman

    ChapoGuzman BANNED BANNED

    Joined:
    Jun 7, 2013
    Messages:
    294
    Likes Received:
    187
    still looking...............
     
  5. umerjutt00

    umerjutt00 Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 28, 2011
    Messages:
    3,644
    Likes Received:
    1,904
    Occupation:
    Ninja
  6. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    hm...

    you need to install node.js

    put the script in a file and execute these commands in the same directory
    Code:
    npm install request
    npm install line-reader
    npm install cheerio
    

    Code:
    var lineReader = require('line-reader');
    var request = require('request');
    var cheerio = require('cheerio');
    var fs = require('fs');
    var http = require('http');
    
    
    var max = 10;
    var infile = 'check.csv';
    var outfile = 'table.csv';
    
    
    var running = 0;
    var output = fs.createWriteStream(outfile, { encoding:'utf8'} );
    http.globalAgent.maxSockets = max;
    
    var linecb = null;
    function next() {
    	if ( running == max )
    		return;
    	if ( linecb == null ) {
    		if ( running == 0 )
    			output.close();
    		return;
    	}
    	linecb();
    }
    
    
    lineReader.eachLine(infile, function(line,last,cb){
    	var cols = line.split(',');
    	linecb = cb;
    	if ( last )
    		linecb = null;
    	
    	if ( cols.length != 2 )
    		next();
    
    	++running;
    	console.log('looking in',cols[0],'for',cols[1]);
    	request('http://'+cols[0]+'.blogspot.com', function(error,response,body){
    		--running;
    		if ( error ) {
    			console.log('error getting '+cols[0]+': '+error);
    		} else {
    			var ch = cheerio.load( body );
    			ch('a[href="http://'+cols[1]+'.blogspot.com/"]').first().each( function(){
    				console.log('found',cols[1] );
    				output.write( cols[1]+'\n' );
    			});
    		}
    		next();
    	});
    	next();
    });
    
     
  7. ChapoGuzman

    ChapoGuzman BANNED BANNED

    Joined:
    Jun 7, 2013
    Messages:
    294
    Likes Received:
    187
    what up man, im on skype all the time hit me up whenever, im just trying to clean up a list.

    Thanks for this complete setup, I installed node, install nmp in the same directory, and I run the script node <script name> and it runs through it just doesnt spit out the output in the table.csv, any idea?
     
  8. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    950
    Likes Received:
    662
    Occupation:
    Web/Bot Developer
    Are you sure your table.csv file is writeable?
     
  9. ChapoGuzman

    ChapoGuzman BANNED BANNED

    Joined:
    Jun 7, 2013
    Messages:
    294
    Likes Received:
    187

    yeah it is writable and we fixed the problem already thanks to sockpuppet who took time out of his day to help me for free, thanks I truly appreciate it (ignore my last PM I figured it out) thanks again.



    THIS JOB IS CLOSED!