linux上的phantomjs返回空的html源 [英] phantomjs on linux returns empty html source

查看:202
本文介绍了linux上的phantomjs返回空的html源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想使用phantomjs连接到我们的内部文档系统,并打印网站的源代码以备将来使用.

该脚本基本上来自示例:

> 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();  });

我们从phantomjs主页下载了二进制软件包,并将其解压缩到我们的debian jessie服务器中并执行脚本:

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

不幸的是,我们只得到一个空的html源:

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

如果我们正在使用phantomjs的Windows二进制文件在您的一台Windows客户端PC上执行此操作,则它将顺利进行.

当从Debian服务器执行phantomjs脚本时,apache访问日志不显示任何访问. (启用调试的error.log显示至少建立了ssl连接)

我有什么想念的吗?

任何反馈表示赞赏!

谢谢

解决方案

这是SSL证书问题.您提供了正确的开关来忽略ssl错误,但没有在正确的位置. PhantomJS设置开关应位于脚本路径之前

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

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

解决方案

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

这篇关于linux上的phantomjs返回空的html源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆