LoginSignup
1
1

More than 5 years have passed since last update.

mac OSX El Capitan Sierra で phantomjs 入門(Hello, World)

Last updated at Posted at 2016-12-14

インストール

ターミナルでHomebrewからインストール

$ brew install phantomjs

問題なく完了

$ phantomjs -v
2.1.1

適当にphantomjs用の環境作ってチュートリアルを試す
Quick Start|PhantomJS

Hello, World

下記を作成して

hello.js
console.log('Hello, World');
phantom.exit();

実行

$ phantomjs hello.js
Hello, world!
$

screen capture

下記を作成して

cap.js
var page = require('webpage').create();
page.open('http://github.com/', function() {
  page.render('github.png');
  phantom.exit();
});

実行

$ phantomjs cap.js

page.open('http://github.com/', function() {
ここで書かれたURLの画面全体キャプチャが同一ディレクトリに保存されてれば成功(なんでスマホ用画面で取れてんだろ?)

簡易的には以上

1
1
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
1
1