phantomjs on linux returns empty html source

2019-08-15 06:44发布

问题:

we´d like to use phantomjs to connect to a our internal documentation system and print the source code of the website for further usage.

The script is basically from the examples:

> var page = require('webpage').create(),
>     system = require('system');
> 
> page.open('https://servername.domain.net/web/topicname?refresh=on',
> function () {
>     console.log(page.content);
>     phantom.exit();  });

We downloaded the binary package from the phantomjs homepage and extracted it to our debian jessie server and executing the script:

root@servername:/usr/local/share/phantomjs-2.1.1-linux-x86_64/examples# phantomjs script.js --ssl-protocol=any --ignore-ssl-errors=true

Unfortunately we only get a empty html source:

<html><head></head><body></body></html>

If we are executing this on one of your windows client pc´s with the windows binary of phantomjs, it works smoothly.

The apache access log dont show any accesses when the phantomjs script get executed from the debian server. (the error.log with debug enabled show atleast a established ssl connection however)

Is there anything i am missing ?

Any feedback is appreciated!

Thanks

回答1:

It's the SSL certificate issue. You included the correct switches to ignore ssl errors, but not at the right place. PhantomJS setting switches are to go before the script path:

phantomjs --ssl-protocol=any --ignore-ssl-errors=true script.js