├── auto ├── bridge.js └── index.js ├── manual └── index.js ├── package.json └── README.md /auto/bridge.js: -------------------------------------------------------------------------------- 1 | // this is meant to be run in nodejs 2 | 3 | var spawn = require('child_process').spawn; 4 | var Downloader = require('downloader'); 5 | 6 | var loggerConfig = { 7 | type: "file", 8 | details: { 9 | filename: 'error.log' 10 | } 11 | } 12 | var logger = require('logger-generator')(loggerConfig) 13 | var downloader = new Downloader(logger); 14 | var decaptcha = spawn('node', [require.resolve('decaptcher/run.js')]); 15 | 16 | decaptcha.stdout.pipe(process.stdout); 17 | downloader.pipe(process.argv[2], decaptcha.stdin) -------------------------------------------------------------------------------- /auto/index.js: -------------------------------------------------------------------------------- 1 | var flow = require('./node_modules/q'); 2 | var spawn = require("child_process").spawn; 3 | 4 | Decaptcha = function() {} 5 | Decaptcha.prototype = { 6 | solve: function(captchaUrl) { 7 | var captchaReady = flow.defer(); 8 | var decaptcha = spawn('node', ['bridge.js', captchaUrl]); 9 | var text = ''; 10 | decaptcha.stdout.on('data', function(data) { 11 | text = text + data; 12 | }) 13 | decaptcha.on("exit", function () { 14 | captchaReady.resolve(text); 15 | }) 16 | return captchaReady.promise; 17 | } 18 | } 19 | 20 | exports = module.exports = Decaptcha; -------------------------------------------------------------------------------- /manual/index.js: -------------------------------------------------------------------------------- 1 | var system = require('system'); 2 | var spawn = require("child_process").spawn 3 | var flow = require('./node_modules/q'); 4 | 5 | var Decaptcha = function(tempDir) { 6 | this.tempDir = tempDir; 7 | } 8 | Decaptcha.prototype = { 9 | solve: function(captchaUrl) { 10 | var captchaReady = flow.defer(); 11 | var filepath = this.tempDir+'/captcha.jpg'; 12 | var downloader = spawn('curl', ['-k', '-o', filepath, captchaUrl]); 13 | 14 | downloader.on("exit", function (code) { 15 | system.stdout.writeLine('Type in text from: '+filepath); 16 | var line = system.stdin.readLine(); 17 | captchaReady.resolve(line.trim()); 18 | }) 19 | return captchaReady.promise; 20 | } 21 | } 22 | exports = module.exports = Decaptcha; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phantomjs-decaptcher", 3 | "description": "Automatic and manual(typing) solving of CAPTCHAS for phantomjs", 4 | "version": "0.0.1", 5 | "author": { 6 | "name": "Общество", 7 | "email": "info@obshtestvo.bg" 8 | }, 9 | "main": "./index.js", 10 | "dependencies": { 11 | "q": "*", 12 | "phantomjs-nodify": "git://github.com/jgonera/phantomjs-nodify.git", 13 | "decaptcher": "git+https://github.com/obshtestvo-utilities/node-decaptcher.git", 14 | "logger-generator": "git+https://github.com/obshtestvo-utilities/node-logger-generator.git", 15 | "downloader": "git+https://github.com/obshtestvo-utilities/node-downloader.git" 16 | }, 17 | "keywords": [ 18 | "phantomjs", 19 | "bridge", 20 | "decaptcha", 21 | "captcha", 22 | "user-input" 23 | ] 24 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## phantom-decaptcha 2 | CAPTCHA solving for phantomjs via nodejs librarires. 3 | 4 | ## Requirements 5 | Requires both `phantomjs` and `nodejs`. 6 | 7 | It also needs a `require('./node_modules/phantomjs-nodify')` in the start of your phantomjs script. 8 | This minimizes the gap between nodejs and phantomjs. 9 | 10 | ## Comes with 11 | 12 | - script for manual solving of CAPTCHA by downloading the image and offering the user to type the text 13 | in the command line. 14 | - automatic solving of CAPTCHA via decaptcha services (currently only `deathbycaptcha`) 15 | 16 | ### Caveats 17 | Because `phantomjs` can't download files there's a script ([auto/bridge.js](auto/bridge.js)) that acts 18 | as a bridge between the nodejs decaptcha library (that accepts a stream of data) and phantomjs. 19 | 20 | It's doing so by simply downloading a file and streaming it to the decaptcha. --------------------------------------------------------------------------------