2011-05-26 01:00:22 +04:00
|
|
|
var page = new WebPage(),
|
|
|
|
t, address;
|
|
|
|
|
|
|
|
if (phantom.args.length === 0) {
|
|
|
|
console.log('Usage: loadspeed.js <some URL>');
|
2010-12-27 09:45:16 +03:00
|
|
|
phantom.exit();
|
2011-05-26 01:00:22 +04:00
|
|
|
} else {
|
2011-06-07 10:52:39 +04:00
|
|
|
t = Date.now();
|
|
|
|
address = phantom.args[0];
|
2011-05-26 01:00:22 +04:00
|
|
|
page.open(address, function (status) {
|
|
|
|
if (status !== 'success') {
|
|
|
|
console.log('FAIL to load the address');
|
|
|
|
} else {
|
|
|
|
t = Date.now() - t;
|
|
|
|
console.log('Page title is ' + page.evaluate(function () {
|
|
|
|
return document.title;
|
|
|
|
}));
|
|
|
|
console.log('Loading time ' + t + ' msec');
|
|
|
|
}
|
|
|
|
phantom.exit();
|
|
|
|
});
|
2010-12-27 09:45:16 +03:00
|
|
|
}
|