page.evaluate()
is the sandboxed page context in PhantomJS. It has no access to variables defined outside. Also, if you want to see console messages from the page context, you need to register to the page.onConsoleMessage
event. You don't need the page context in this case.
The other problem is that PhantomJS version < 1.9.8 uses SSLv3 by default, but because of the POODLE vulnerability most webservers have disabled SSLv3 support, so you need to explicitly add the --ssl-protocol=tlsv1
commandline option.
Working code with PhantomJS 1.9.0:
page.open(url, function (status) {
console.log("status: " + status);
phantom.exit();
});
Of course, if you really want to pass the status into the page context for whatever reason, you need to pass it explicitly:
page.onConsoleMessage = function(msg){
console.log("page: " + msg);
};
page.open(url, function (status) {
page.evaluate(function(status){
console.log("status: " + status);
}, status);
phantom.exit();
});