Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/netlog.js
164 views
1
var page = require('webpage').create(),
2
system = require('system'),
3
address;
4
5
if (system.args.length === 1) {
6
console.log('Usage: netlog.js <some URL>');
7
phantom.exit(1);
8
} else {
9
address = system.args[1];
10
11
page.onResourceRequested = function (req) {
12
console.log('requested: ' + JSON.stringify(req, undefined, 4));
13
};
14
15
page.onResourceReceived = function (res) {
16
console.log('received: ' + JSON.stringify(res, undefined, 4));
17
};
18
19
page.open(address, function (status) {
20
if (status !== 'success') {
21
console.log('FAIL to load the address');
22
}
23
phantom.exit();
24
});
25
}
26
27