我想解析一个HTTPS网页,但是当我这样做时它是空白的。所以我认为这与SSL证书有关。我怎么能忽视这一点呢?
我使用php-phantomjs.
在问题PhantomJS无法打开HTTPS站点中看到,您可能需要添加以下命令行选项来修复SSL/TLS问题:
phantomjs --ssl-protocol=any --ignore-ssl-errors=true --web-security=false script.js
在php-phantomjs中的用法略有不同,但您可以使用:
$client = Client::getInstance();
$client->getEngine()->addOption('--ssl-protocol=any');
$client->getEngine()->addOption('--ignore-ssl-errors=true');
$client->getEngine()->addOption('--web-security=false');
或加载配置。Json文件如下:
$client->getEngine()->addOption('--config=/path/to/config.json');
json:
{
"sslProtocol": "any",
"ignoreSslErrors": true,
"webSecurityEnabled": false
}
在旧版本的php-phantomjs中,必须使用$client->addOption(...)
而不是$client->getEngine()->addOption(...)