Streaming interface to the PhantomJS headless browser
First off, install the
npm install phantomstream
Next, create a simple script named "myscript.js".
phantomstream =// Open up a PhantomJS stream that listens for commands that look like// "TITLE <url>". Browse to the URL and write the title back via the stream.var conf = logger: consolevar ps = phantomstream// Send an TITLE command to our PhantomJS process and echo the response.psps
Run your script with node.
...you should see output like this:
[phantom-stdout] opening http://www.google.com [phantom-stdout] sending title = Google node received: Google
Enjoy! For more ideas on what is possible inside the callback for
phantomstream.open(), read the
Don't forget try out some demos from the
examples/ directory :)
If you are looking for higher-level implementations that wrap the PhantomJS API, check these out: