You might want to look at the onResourceReceived
on the page object, you can get what you need from it. ( API docs ... )
This is a slightly contrived example, and it will return a status code for each resource received as part of the request, but the page itself will be the first (i.e., unlike JS or CSS support, etc.):
var page = require('webpage').create(); page.onResourceReceived = function(res) { if (res.stage === 'end') { console.log('Status code: ' + res.status); } }; page.open('http://some.url/that/does-not-exist', function() { phantom.exit(); });
Of course, this assumes that the server will actually return you 404 (unlike 200 masquerades, for example, 404), but something in this direction should give you what you want.
source share