can phantomjs work with node.js?

前端 未结 7 1703
难免孤独
难免孤独 2020-11-30 03:56

I would like to use phantomjs in my node.js script. there is a phantomjs-node library.. but unfortunately the author used this weird coffee script code to explain what he\'s

相关标签:
7条回答
  • 2020-11-30 04:39

    I am now the new maintainer for phantom-node package. It doesn't use coffeescript anymore. You can do something like

    var phantom = require('phantom');
    
    phantom.create().then(function(ph) {
      ph.createPage().then(function(page) {
        page.open('https://stackoverflow.com/').then(function(status) {
          console.log(status);
          page.property('content').then(function(content) {
            console.log(content);
            page.close();
            ph.exit();
          });
        });
      });
    });
    

    The new version is much faster and resilient. It also doesn't use websockets anymore.

    0 讨论(0)
提交回复
热议问题