PhantomJS
Hello World
Simple example how to use PhantomJS. Notice that I will write JS script and then execute that script from terminal.
That's beacuse PhantomJS is a terminal based application. To see all comand line options type:
$phantomjs --help
So let's write our first script:
Execute that script with: $phantomjs 00helloworld.js
Output: Hello world!
Notice if you don't write exit() then process will not be killed. Just open another another terminal and run:
$ps -aux | grep phantomjs
POSIX EXIT STATUS
- EXIT_SUCCESS = exit(0) -program exits after successfull completition
- EXIT_SUCCESS = exit(1) -program exits due to error
To kill all phantom processes use:
$sudo killall -9v phantomjs
$sudo killall -9v node