mirror of https://github.com/vitalif/phantomjs
23 lines
629 B
JavaScript
23 lines
629 B
JavaScript
var page = require('webpage').create(),
|
|
t, address;
|
|
|
|
if (phantom.args.length === 0) {
|
|
console.log('Usage: loadspeed.js <some URL>');
|
|
phantom.exit();
|
|
} else {
|
|
t = Date.now();
|
|
address = phantom.args[0];
|
|
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();
|
|
});
|
|
}
|