LoginSignup
7
7

More than 5 years have passed since last update.

PhantomJSで指定URLのスクリーンショットを保存してみた

Last updated at Posted at 2014-07-17

投稿のお試しも兼ねて。

get.js
var  page = require('webpage').create()
    ,system = require('system')
    ,ua, url, output;

if (system.args.length != 4) {
    console.log('[Error] Invalid Argument...');
    phantom.exit();
} else {
    url = system.args[1];
    output = system.args[2];
    ua = system.args[3];

    page.settings.userAgent = ua;
    page.open(url, function (status) {
        if (status !== 'success') {
            console.log('[Error] Unable to load the [' + url + '] ...');
            phantom.exit();
        } else {
            window.setTimeout(function () {
                page.render(output);
                console.log(page.content);
                phantom.exit();
            }, 200);
        }
    });
}
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7