Created
September 9, 2015 15:57
-
-
Save hkusu/27f8492a635ebaa1eeb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // $ casperjs --ignore-ssl-errors=yes check-google-play.js https://play.google.com/store/apps/details?id=jp.nailbook | |
| var casper = require('casper').create(); | |
| var url = casper.cli.get(0); // コマンドライン引数からスクレイピング対象のURLを取得 | |
| var results = []; | |
| casper.start(url, function() { | |
| // 対象のURLにアクセスし条件に一致するタグの中身を取得 | |
| results = this.evaluate(function() { | |
| var elements = document.querySelectorAll('.content[itemprop=\"softwareVersion\"]'); | |
| return Array.prototype.map.call(elements, function(e) { | |
| return e.innerHTML; | |
| }); | |
| }); | |
| // 余分な半角スペースを削除 | |
| var i, length = results.length; | |
| for (i = 0; i < length; i++) { | |
| results[i] = results[i].replace(/\ /g,""); | |
| } | |
| //this.capture('foo.png'); // もしキャプチャ画像もとる場合 | |
| }); | |
| casper.run(function() { | |
| this.echo(results.join(' ')); // 複数ある場合は半角スペースでつなぐ | |
| this.exit(); // 終了 | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment