相关疑难解决方法(0)

通过exec将变量传递给PhantomJS

我开始使用Grunt并希望将变量传递给我通过exec运行的PhantomJS脚本.我希望能够做的是传递一个url,让脚本从中获取屏幕截图.任何帮助将不胜感激,谢谢!

达伦

Grunt脚本

exec('phantomjs screenshot.js',
    function (error, stdout, stderr) {
        // Handle output
    }
);
Run Code Online (Sandbox Code Playgroud)

screenshot.js

var page = require('webpage').create();
page.open('http://google.com', function () {
    page.render('google.png');
    phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)

javascript command-line-interface node.js phantomjs gruntjs

8
推荐指数
2
解决办法
1万
查看次数