1

I'm new to Phantomjs.I have tried to load the page using the below code.But the given page is not loading while running this.

  console.log('Loading a web page');
  var page = require('webpage').create();
  var url = 'http://www.phantomjs.org/';
  page.open(url, function (status) {
     //Page is loaded!
      phantom.exit();
  });
4

1 回答 1

4

Your code is correct but you have to do something before phantom.exit();

See all examples here. Let's capture a web page as a screenshot :

console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://www.phantomjs.org/';
page.open(url, function (status) {
    //Page is loaded!
    page.render('phantomjs.png');
    phantom.exit();
});
于 2013-05-03T12:35:08.110 回答