Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/loadspeed.js
164 views
1
var page = require('webpage').create(),
2
system = require('system'),
3
t, address;
4
5
if (system.args.length === 1) {
6
console.log('Usage: loadspeed.js <some URL>');
7
phantom.exit(1);
8
} else {
9
t = Date.now();
10
address = system.args[1];
11
page.open(address, function (status) {
12
if (status !== 'success') {
13
console.log('FAIL to load the address');
14
} else {
15
t = Date.now() - t;
16
console.log('Page title is ' + page.evaluate(function () {
17
return document.title;
18
}));
19
console.log('Loading time ' + t + ' msec');
20
}
21
phantom.exit();
22
});
23
}
24
25