Fedora-27-Linux-命令行url截图-PhantomJS

dnf install nodejs -y
dnf install bzip2 -y

npm install phantomjs-bin
npm install phantom
npm install phantomjs

ln -s /root/node_modules/phantomjs/bin/phantomjs /bin/

phantomjs ~/rasterize.js  https://github.com github.png


rasterize.js

"use strict";
var page = require('webpage').create(),
    system = require('system'),
    address, output, size, pageWidth, pageHeight;

    address = system.args[1];
    output = system.args[2];

page.open(address, function (status) {
  //Page is loaded!
  window.setTimeout(function () {
      page.paperSize = { width: 1366, height: 768 };
      page.viewportSize = { width: 1366, height: 768 };
      page.clipRect = { top: 0, left: 0, width: 1366, height: 768 };
      page.render(output);
      phantom.exit();
  }, 2000);


});