I'm attempting to use PhantomJS, and I've installed it via NPM. I can't seem to run any of the of the examples, in fact I can't even run:
var page = require('webpage').create();
I get the error:
Error: Cannot find module 'webpage'
Is there anything i'm missing? I'm using a few other modules that I've installed via NPM in the same directory with no issues
Not Suitable for Heavy-Computing Apps Node. js doesn't support multi-threaded programming yet. It is able to serve way more complicated applications than Ruby, but it's not suitable for performing long-running calculations. Heavy computations block the incoming requests, which can lead to decrease of performance .
PhantomJS is a discontinued headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment.
js for CPU-intensive operations; in fact, using it for heavy computation will annul nearly all of its advantages. Where Node really shines is in building fast, scalable network applications, as it's capable of handling a huge number of simultaneous connections with high throughput, which equates to high scalability.
Node JS uses an asynchronous event-driven I/O model, ensuring that almost no function in Node directly performs I/O. That makes it lightweight and efficient.
If you want to use a module to work with PhantomJS in Node.js, you can use the phantom module written by @amir20. This module offers integration for PhantomJS in Node.js. Although the workflow with Javascript ain't the same that the Javascript that you use to instruct PhantomJS, it's still easy to understand.
There are some html and CSS issues which you might face while generating/converting your html to PDF using nodejs and Phantomjs. 1. Problem in including Bootstrap library if you are using bootstrap in your html and you are using the library in your folder and setting it's path it might not work.
Thus, if PhantomJS works well with HTTP but it shows some problem when using HTTPS, the first useful thing to check it whether the SSL libraries, usually OpenSSL, have been installed properly. On Windows, the default proxy setting may cause a massive network latency (see Known Issues in the release note).
If some examples do not work, make sure that there is not more than one version of PhantomJS installed in the system. Multiple versions may lead to conflict as to which one is being invoked in the terminal.
PhantomJS is not for Node.js. You are likely running the examples through node
binary.
Read the Getting Started documentation carefully and you'll see that every single PhantomJS example need to be invoked like:
phantomjs hello.js
Note that there is a bridge between Node.js and PhantomJS. In that case, you need to follow the given examples for that particular bridge (there are a few different ones).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With