netlog.coffee 518 B

123456789101112131415161718
  1. page = require('webpage').create()
  2. system = require 'system'
  3. if system.args.length is 1
  4. console.log 'Usage: netlog.coffee <some URL>'
  5. phantom.exit 1
  6. else
  7. address = system.args[1]
  8. page.onResourceRequested = (req) ->
  9. console.log 'requested ' + JSON.stringify(req, undefined, 4)
  10. page.onResourceReceived = (res) ->
  11. console.log 'received ' + JSON.stringify(res, undefined, 4)
  12. page.open address, (status) ->
  13. if status isnt 'success'
  14. console.log 'FAIL to load the address'
  15. phantom.exit()