我想解析一个HTTPS网页,但是在我这么做时它是空白的。所以我认为这与SSL证书有关。我该如何忽略它呢?
我正在使用 php-phantomjs。
我想解析一个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');
或者像这样加载一个 config.json 文件:
$client->getEngine()->addOption('--config=/path/to/config.json');
config.json:
{
"sslProtocol": "any",
"ignoreSslErrors": true,
"webSecurityEnabled": false
}
在较旧版本的php-phantomjs中,需要使用$client->addOption(...)
而不是$client->getEngine()->addOption(...)
。