2015-04-10 10:51:00 +03:00
|
|
|
"use strict";
|
2011-09-13 00:17:54 +04:00
|
|
|
var page = require('webpage').create(),
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require('system'),
|
|
|
|
address;
|
2011-09-10 20:15:34 +04:00
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
if (system.args.length === 1) {
|
2011-09-10 20:15:34 +04:00
|
|
|
console.log('Usage: netlog.js <some URL>');
|
2012-05-16 11:37:26 +04:00
|
|
|
phantom.exit(1);
|
2011-09-10 20:15:34 +04:00
|
|
|
} else {
|
2012-01-14 19:13:26 +04:00
|
|
|
address = system.args[1];
|
2011-09-10 20:15:34 +04:00
|
|
|
|
|
|
|
page.onResourceRequested = function (req) {
|
|
|
|
console.log('requested: ' + JSON.stringify(req, undefined, 4));
|
|
|
|
};
|
|
|
|
|
|
|
|
page.onResourceReceived = function (res) {
|
|
|
|
console.log('received: ' + JSON.stringify(res, undefined, 4));
|
|
|
|
};
|
|
|
|
|
|
|
|
page.open(address, function (status) {
|
|
|
|
if (status !== 'success') {
|
|
|
|
console.log('FAIL to load the address');
|
|
|
|
}
|
|
|
|
phantom.exit();
|
|
|
|
});
|
|
|
|
}
|