Przekazanie wartości z PhantomJS do node.js
Mam skrypt phantomJS, który jest wykonywany za pośrednictwemexec()
wywołanie w skrypcie node.js. Teraz muszę zwrócić ciąg ze skryptu PhantomJS, aby można go było wykorzystać z powrotem w węźle.
Czy istnieje sposób, aby to osiągnąć?
Aplikacja węzła:
child = exec('./phantomjs dumper.js',
function (error, stdout, stderr) {
console.log(stdout, stderr); // Always empty
});
dumper.js (Phantom)
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
});