BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / netlog.js

netlog.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
netlog.js 671 B Download Raw
1"use strict";
2var page = require('webpage').create(),
3 system = require('system'),
4 address;
5
6if (system.args.length === 1) {
7 console.log('Usage: netlog.js <some URL>');
8 phantom.exit(1);
9} else {
10 address = system.args[1];
11
12 page.onResourceRequested = function (req) {
13 console.log('requested: ' + JSON.stringify(req, undefined, 4));
14 };
15
16 page.onResourceReceived = function (res) {
17 console.log('received: ' + JSON.stringify(res, undefined, 4));
18 };
19
20 page.open(address, function (status) {
21 if (status !== 'success') {
22 console.log('FAIL to load the address');
23 }
24 phantom.exit();
25 });
26}