Skip to content

Instantly share code, notes, and snippets.

@king-panda
Last active August 29, 2015 14:20
Show Gist options
  • Save king-panda/42172a361c139f9ab0ed to your computer and use it in GitHub Desktop.
Save king-panda/42172a361c139f9ab0ed to your computer and use it in GitHub Desktop.
【CasperJS】Facebookをスクレイピングして近況を投稿してみる ref: http://qiita.com/kingpanda/items/f11cfa9d4e527024d75b
$ npm install -g phantomjs
$ npm install -g casperjs
$ casperjs sample.js
var casper = require("casper").create();
//フェイスブックにログインする
casper.start("https://ja-jp.facebook.com/", function(){
//ログイン
this.fill('.menu_login_container > form',
{ email: 'フェイスブックの登録メールアドレス', pass: 'フェイスブックのパスワード' }, true);
});
//近況を投稿
casper.then(function(){
casper.wait(5000, function() {
this.evaluate(function() {
document.querySelector('#u_0_11').value = 'お化けがでたよー by CasperJS';
document.querySelector('#u_0_x > div > div._1dsp > div > ul > li:nth-child(2) > button').click();
});
});
});
//結果のキャプチャを撮る
casper.wait(10000, function() {
this.capture('result.png');
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment