Is it possible to run PhantomJS from node.js as a command line argument

后端 未结 3 832
挽巷
挽巷 2020-12-04 18:53

I was recently going to test out running phantomJS from python as a commandline argument, I haven\'t got round to it yet but have seen examples. Because PhantomJS is run fro

3条回答
  •  一整个雨季
    2020-12-04 19:21

    From NPM: https://npmjs.org/package/phantomjs

    var path = require('path')
    var childProcess = require('child_process')
    var phantomjs = require('phantomjs')
    var binPath = phantomjs.path
    
    var childArgs = [
      path.join(__dirname, 'phantomjs-script.js'),
      'some other argument (passed to phantomjs script)'
    ]
    
    childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
      // handle results
    })
    

提交回复
热议问题