0

i want to use this phantom code but with node.js, but i don't find the equivalent of system.args[1] in node.js

    var phantom = require('phantom');
   // var page = new WebPage();
   // var system = require('system');
   // var sBlob = system.args[1];
    var sUrl = 'file:///C:/Users/editor.html?Blob='+sBlob;
    phantom.create(function(ph) {
        ph.createPage(function(page) {
            page.open(sUrl, function(status) {
                console.log("opened diagram? ", status);
                page.evaluate(function() {
                    return document.getElementById("GraphImage").src;
                }, function(result) {
                    console.log(result)

                    ph.exit();
                });
            });
        });
    }, {
        dnodeOpts : {
            weak : false
        }
    });
ameni
  • 393
  • 2
  • 8
  • 17
  • 3
    Possible duplicate of [How to pass command line arguments to Node.js?](http://stackoverflow.com/questions/4351521/how-to-pass-command-line-arguments-to-node-js) – SWeko Dec 16 '15 at 12:35
  • @sweko i want to be able to pass sBlob which is the input of the url – ameni Dec 16 '15 at 12:49

1 Answers1

0

If you are running your script as $ node script.js theargument

you should be able to get it using

// the first argument is node and 
//the second is the script name, none of them should be relevant
var args = process.argv.slice(2);
var sBlob = args[0];
Morten Olsen
  • 1,806
  • 14
  • 18