exec()
node.jsスクリプトの呼び出しを介して実行されるphantomJSスクリプトがあります。次に、PhantomJSスクリプトから文字列を返して、ノードで使用できるようにする必要があります。
それを達成する方法はありますか?
ノードアプリ:
child = exec('./phantomjs dumper.js',
function (error, stdout, stderr) {
console.log(stdout, stderr); // Always empty
});
dumper.js(ファントム)
var system = require('system');
var page = require('webpage').create();
page.open( system.args[1], function (status) {
if (status !== 'success') {
console.log('Unable to access the network!');
} else {
return "String"; // Doesn't work
}
phantom.exit('String2'); //Doesn't work either
});