Reputation: 10095
If I change this:
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return page.open("http://www.google.com", function(status) {
console.log("opened google? ", status);
return page.evaluate((function() {
return document.title;
}), function(result) {
console.log('Page title is ' + result);
return ph.exit();
});
});
});
});
to this:
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return page.open("http://www.google.com", function(status) {
console.log("opened google? ", status);
return page.get('title',(function(title) {
return title;
}), function(result) {
console.log('Page title is ' + result);
return ph.exit();
});
});
});
});
Node hangs at the console after printing 'opened google? success'and there is no further output.
I am trying to use page.get() instead of page.evaluate as described in the phantom module docs:
Properties can't be get/set directly, instead use p.get('version', callback)
Upvotes: 2
Views: 253
Reputation: 17038
You misuse page.get()
. This method has only two arguments, not three.
Here's how to it:
page.get('title', function(title) {
console.log('Page title is ' + title);
return ph.exit();
});
Upvotes: 2