Простой скрипт, повторяю все как в видео - но не пашет.
var system = require('system');
var args = system.args;
var url = 'http://packtpub.com/';
var page = require('webpage');
// START
page.onError = function(msg, trace) {
var msgStack = ['ERROR: ' + msg];
if (trace && trace.length) {
msgStack.push('TRACE:');
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
});
}
console.error(msgStack.join('\n'));
phantom.exit(1);
};
// END
// handler for reciever resources
page.onResourceReceived = function(response) {
console.log(response.contentType);
};
// react to any loaded page
page.onLoadFinished = function() {
console.log('************');
console.log('Page loaded');
phanton.exit();
};
page.open( url );
Консоль пишет:
TypeError: undefined is not a function (evaluating 'page.open( url )')
phantomjs://code/network.js:37 in global code