var page = require('webpage').create();
page.onConsoleMessage = function (msg) {
console.log('Inner log: ' + msg);
};
var url = "http://www.w3.org/TR/CSS21/propidx.html";
page.open(url, function() {
console.log("status ",status);
var props = page.evaluate(function() {
var x = document.getElementsByClassName('xref');
for (var i=0;i<x.length;++i) {
console.log(x[i].innerText);
}
...
出力:
❯ phantomjs css21_parser.js
2013-03-17 03:27:01.737 phantomjs[95167:707] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
status
Inner log: 'azimuth'
Inner log: 'background-attachment'
Inner log: 'background-color'
Inner log: 'background-image'
Inner log: 'background-position'
Inner log: 'background-repeat'
....
基本的に、例と API ドキュメントでは、成功は「成功」に対してチェックする必要があると記載されていますが、この場合、空の文字列のように見えます。