2

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)

1 Answer 1

2

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();
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.