phantomjs on linux returns empty html source

纵然是瞬间 提交于 2019-12-24 14:47:18

问题


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


来源:https://stackoverflow.com/questions/35198893/phantomjs-on-linux-returns-empty-html-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!