2011-09-13 00:17:54 +04:00
|
|
|
page = require('webpage').create()
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require 'system'
|
2011-09-10 20:15:34 +04:00
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
if system.args.length is 1
|
2011-09-10 20:15:34 +04:00
|
|
|
console.log 'Usage: netlog.coffee <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 = (req) ->
|
|
|
|
console.log 'requested ' + JSON.stringify(req, undefined, 4)
|
|
|
|
|
|
|
|
page.onResourceReceived = (res) ->
|
|
|
|
console.log 'received ' + JSON.stringify(res, undefined, 4)
|
|
|
|
|
2011-09-10 22:05:25 +04:00
|
|
|
page.open address, (status) ->
|
2011-09-10 20:15:34 +04:00
|
|
|
if status isnt 'success'
|
|
|
|
console.log 'FAIL to load the address'
|
|
|
|
phantom.exit()
|