Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Is it possible to run PhantomJS from node.js as a command line argument

Is it possible to run PhantomJS from node.js as a command line argument


I was recently going to test out running Phantomjs from python as a commandline argument, I haven't got round to it yet but have seen examples. Because PhantomJS is run from the command line this seems to be possible. The result that PhantomJS would spit out would go straight into a variable.

Before I go down that path, making this work in node.js would actually be more useful for me and it got me thinking, can i just use to node to run PhantomJS as a program gets run from the commandline and store the data result that PhantomJS would normally spit out into a variable?

I would rather not use phantomjs-node because it seems to be using too many tricks.

The reason for all of this is to be able to run PhantomJS at the same time as another action the program takes and use the resulting data its recorded for some other stuff.

Simply put, you can run system command line stuff in python, can I do the same in node.js?

Cheers :)

Edit: I understand that node and phantom use different js environments, that's cool because I just want to run phantom as its own process and catch all that output data into a node.js variable (the data will be a array of a pair, string and floating point.) I don't want to 'drive' with phantom, I will craft the loaded javascript files todo what I want. All I want is phantom output. :)

Problem courtesy of: Joseph


I suppose you can make a simple script for Node.js to run; in that script phantomjs script will be run as a child process. You can see the working example (and links for some documentation) in this answer. I suppose this discussion might be helpful for you as well.

Solution courtesy of: raina77ow


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Is it possible to run PhantomJS from node.js as a command line argument


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription