From 6404201add89a3c6ad0bda78349a992a7ed346f7 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 18 Dec 2013 21:36:55 +0100 Subject: [PATCH] Passing through Phantomjs options --- index.js | 26 ++++++++++++++++++++++---- phantomas.js | 5 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index e9153d497..4faea3c89 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ var debug = require('debug')('phantomas'), function phantomas(url, options, callback) { var args = [], + phantomJsArgs = [], events = new emitter(), path = '', proc, @@ -38,19 +39,36 @@ function phantomas(url, options, callback) { // build args Object.keys(options).forEach(function(key) { - var val = options[key]; + var val = options[key], + nativeOptions = [ + 'cookies-file', + 'ignore-ssl-errors', + 'proxy', + 'proxy-auth', + 'proxy-type' + ]; if (val === false) { return; } - args.push('--' + key); + // handle native PhantomJS options (#163) + // @see http://phantomjs.org/api/command-line.html + if (nativeOptions.indexOf(key) > -1) { + phantomJsArgs.push('--' + key + '=' + val); + } + else { + args.push('--' + key); - if (val !== true) { - args.push(val); + if (val !== true) { + args.push(val); + } } }); + // add native PhantomJS options + args = phantomJsArgs.concat(args); + debug('Running %s %s', path, args.join(' ')); // spawn the process diff --git a/phantomas.js b/phantomas.js index c8a6ed252..f28a00b43 100755 --- a/phantomas.js +++ b/phantomas.js @@ -30,11 +30,16 @@ program .describe('config', 'uses JSON-formatted config file to set parameters') .describe('cookie', 'document.cookie formatted string for setting a single cookie (e.g. "bar=foo;domain=url")') .describe('cookie-jar', 'persistent cookie JAR across requests') + .describe('cookies-file', 'specifies the file name to store the persistent Cookies') .describe('disable-js', 'disable JavaScript on the page that will be loaded').boolean('disable-js') .describe('format', 'output format').default('format', 'plain') + .describe('ignore-ssl-errors', 'ignores SSL errors, such as expired or self-signed certificate errors') .describe('log', 'log to a given file') .describe('modules', 'run selected modules only [moduleOne],[moduleTwo],...') .describe('no-externals', 'block requests to 3rd party domains').boolean('no-externals') + .describe('proxy', 'specifies the proxy server to use (e.g. --proxy=192.168.1.42:8080)') + .describe('proxy-auth', 'specifies the type of the proxy server (default is http)') + .describe('proxy-type', 'specifies the authentication information for the proxy (e.g. --proxy-auth=username:password)') .describe('screenshot', 'render fully loaded page to a given file') .describe('silent', 'don\'t write anything to the console').boolean('silent') .describe('skip-modules', 'skip selected modules [moduleOne],[moduleTwo],...')