0
var page = require('webpage').create();
page.open(url, function (status) {
    if (status === 'fail') {
        console.log("fail");
    } else {
        console.log(page.evaluate(function () {
            var t0 = document.body.innerHTML;
            return t0;

        }));
    }
    phantom.exit();
});   

When I do this way, I can't get the html generated from js.

1 Answer 1

1

This is not the correct way to return anything from the page scope to the phantom's scope.

You should consider using

window.callPhantom method and page.onCallback event.

Sign up to request clarification or add additional context in comments.

3 Comments

That helps me.But evaluate sometimes works, and sometimes doesn't work?
What problems do you face?
I got it. It's because of Dom tree generating without 'WaitTimeout'.

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.