我想解析一个 HTTPS 网页,但解析时它是空白的。 所以我认为这与SSL证书有关。 我怎么能忽略这个?
我正在使用 php-phantomjs .
最佳答案
如问题 PhantomJS failing to open HTTPS site 中所示,您可能需要添加以下命令行选项来修复 SSL/TLS 问题:
phantomjs --ssl-protocol=any --ignore-ssl-errors=true --web-security=false script.js
在 php-phantomjs 中的用法是一个 little different , 但您可以使用:
$client = Client::getInstance();
$client->getEngine()->addOption('--ssl-protocol=any');
$client->getEngine()->addOption('--ignore-ssl-errors=true');
$client->getEngine()->addOption('--web-security=false');
或者像这样加载一个 config.json 文件:
$client->getEngine()->addOption('--config=/path/to/config.json');
配置文件:
{
"sslProtocol": "any",
"ignoreSslErrors": true,
"webSecurityEnabled": false
}
在旧版本的 php-phantomjs 中,必须使用 $client->addOption(...)
而不是 $client->getEngine()->addOption(。 ..)
.
关于PHP PhantomJS 忽略 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33334965/