Created
September 8, 2015 11:56
-
-
Save akamajoris/4afa1de0246ab3e183ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var poolModule = require('generic-pool'); | |
var exec = require('child_process').exec; | |
var randomstring = require("randomstring"); | |
var ualist = ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0) Gecko/20100101 Firefox/33.0", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.517 Safari/537.36"]; | |
var urllist = ["http://host.com", "http://host.com/hello", "http://stand.me/2015/"]; | |
var pool = poolModule.Pool({ | |
name : 'emulator', | |
create : function(callback) { | |
var ua = ualist[Math.floor(Math.random()*ualist.length)]; | |
var url = urllist[Math.floor(Math.random()*urllist.length)]; | |
var filename = randomstring.generate(); | |
var cmd = "phantomjs ./render.js " + url + " ./tmp/" + filename + ".jpg " + "\"" + ua + "\""; | |
var task = exec(cmd); | |
console.log(cmd); | |
callback(null, ua); | |
}, | |
destroy : function(client) { /*client.end();*/ }, | |
max : 25, | |
min : 10, | |
idleTimeoutMillis : 15000, | |
log : false | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment