命令行参数可通过模块
require('system').args(Module System)访问。第一个始终是脚本名称,然后是后续参数
该脚本将枚举所有参数,并将其写到控制台。
var args = require('system').args;if (args.length === 1) { console.log('Try to pass some arguments when invoking this script!');}else { args.forEach(function(arg, i) { console.log(i + ': ' + arg); });}在您的情况下,解决方案是
咕unt声
exec('phantomjs screenshot.js http://www.google.fr', function (error, stdout, stderr) { // Handle output });screenshot.js
var page = require('webpage').create();var address = system.args[1];page.open(address , function () { page.render('google.png'); phantom.exit();});


