2018/6/22
Tag : casperjs
CasperJS
CasperJS
CasperJS, a navigation scripting and testing utility for PhantomJS and SlimerJS
http://casperjs.org/
インストール
Homebrewでインストールしてみる
$ brew update
$ brew install casperjs --devel
$ casperjs --version
1.1.0-beta3
インストールできた
Homebrewのアップデートエラー
update したときにエラーになったので、それは別にまとめた。
Homebrewメモ | mersy note
http://mersy.github.io/homebrew.html
http://bit-part.netのタイトルを表示
http://bit-part.netのタイトルを表示させてみる
// sample01.js
var casper = require('casper').create();
casper.start('http://bit-part.net/',function(){
this.echo(this.getTitle());
});
casper.run();
sample01.jsを作成
$ casperjs sample01.js
bit part 合同会社
http://bit-part.netのキャプチャを取得してみる
http://bit-part.netのキャプチャを取得してみる
// sample2.js
var casper = require('casper').create();
casper.start('http://bit-part.net',function(){
this.capture('sample02.png');
});
casper.run();
UAというか幅がすごく細いcaptureが撮れた
幅を広げて撮ってみる
// sample3.js
var casper = require('casper').create();
casper.start('http://bit-part.net');
casper.viewport(1024, 768).then(function() {
this.capture('sample03.png');
});
casper.run();
一応こんな感じで幅広めので撮れた。
APIの使い方
captureのところのAPI
The casper module — CasperJS 1.1.0-DEV documentation
http://docs.casperjs.org/en/latest/modules/casper.html#capture
参考
- API Documentation — CasperJS 1.1.0-DEV documentation
http://docs.casperjs.org/en/latest/modules/index.html - Amazon.co.jp: WEB+DB PRESS Vol.80
http://www.amazon.co.jp/exec/obidos/ASIN/4774163988/mersys-22/ref=nosim