Skip to content

Instantly share code, notes, and snippets.

@kaizhu256
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaizhu256/6637fa028d526b2c236d to your computer and use it in GitHub Desktop.
Save kaizhu256/6637fa028d526b2c236d to your computer and use it in GitHub Desktop.
screen capture using phantomjs
/*
phantomjs-capture.js from https://gist.github.com/kaizhu256/6637fa028d526b2c236d
usage example:
$ phantomjs phantomjs-capture https://www.google.com gooogle.png 5000
*/
/*jslint browser: true, indent:2, node: true, nomen: true*/
/*global phantom*/
(function submoduleCapturePhantomjs() {
/*
this phantomjs submodule captures a webpage
*/
'use strict';
var local;
local = {
_name: 'utility2.submoduleCapturePhantomjs',
_init: function () {
var args, page;
args = require('system').args;
page = require('webpage').create();
page.viewportSize = { height: 768, width: 1024 };
page.open(args[1], function (status) {
console.log('phantomjs - open ' + status + ' ' + args[1]);
setTimeout(function () {
console.log('phantomjs - rendering ' + args[1] + ' to ' + args[2] + ' ...');
page.render(args[2]);
phantom.exit();
}, args[3]);
});
}
};
local._init();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment