Trouble on CasperJS
One of the project we need use CasperJS to navigates dozens URLs, evaluate hundreds lines of javascript in that page then submit the form, sounds crazy right?!
Unfortunately, even we tried our best to optimize the page loading performance, the whole process is take around one hour. We tried initialize multiple instances of CasperJS and running those at same time, but it still failed.
However, we found this blog, by utilizing Parallel, program ables to process CasperJS under multiple threads simultaneously, the following steps similar to that blog except I will list installation parts.
Check CPU cores
Make sure your server has more than 1 core…
|
|
Install CasperJS
|
|
Install Parallel
|
|
Examples
Imagine you will need a list URLs like below and named as list.txt
, or generate it by yourself.
|
|
Then you can use the following command to process those URLs simultaneously.
|
|
HTTP Redirect
If the URL is being forced redirect from http to https, you probably will get redirect and won’t get anything, in this case, add --ignore-ssl-errors=true --ssl-protocol=any
to your command.