You can do it something like this:
var page = require('webpage').create(), system = require('system'), resources = []; page.open('http://google.com', function (status) { console.log('Loaded with http status:', resources[0].status); phantom.exit(); }); page.onResourceReceived = function(response) {
So, if you need to check the status of the first browser request (in this case on the google html page), you should see it as the first returned in resources[0].status . In the onResourceReceived handler, you can add additional filters for the resources from which you are trying to get the http code.
UPDATE: thanks to @fotijr added verification of completed responses
source share