Reputation: 38228
From PhantomJs console I typed
var page = require('webpage').create();page.open('http://phantomjs.org', function (status) {console.log(page.title);});
It doesn't print the page title but only undefined
Why ?
Upvotes: 1
Views: 350
Reputation: 8121
Firstly require("webpage")
is not phantomJS' module, so that's incorrect.
Try use is as outlined in the documentation :
https://github.com/amir20/phantomjs-node
var phantom = require('phantom');
var sitepage = null;
var phInstance = null;
phantom.create()
.then(instance => {
phInstance = instance;
return instance.createPage();
})
.then(page => {
sitepage = page;
page.open('http://phantomjs.org', function(){
console.log("Title : " + page.title);
});
return ;
})
Upvotes: 3