Sha256: 29f13b83824b12820edda83e4d872101612896102d580141f94fa1ac603ae365

Contents?: true

Size: 670 Bytes

Versions: 7

Compression:

Stored size: 670 Bytes

Contents

var page = require('webpage').create(),
    system = require('system'),
    address, output, selector;

if (system.args.length < 2) {
    console.log('Usage: snapa.js URL output [selector]');
    console.log('    opens a page and renders the contents of selector to output file');
    phantom.exit(1);
} else {
    address = system.args[1];
    output = system.args[2];
    selector = system.args[3] || 'body';

    page.open(address, function () {
        page.clipRect = page.evaluate(function(selector) {
            return document.querySelector(selector).getBoundingClientRect();
        }, selector);
        page.render(output);
        phantom.exit();
    });
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
snapa-0.0.8 lib/snapa.js
snapa-0.0.7 lib/snapa.js
snapa-0.0.5 lib/snapa.js
snapa-0.0.4 lib/snapa.js
snapa-0.0.3 lib/snapa.js
snapa-0.0.2 lib/snapa.js
snapa-0.0.1 lib/snapa.js