艾Q网

标题: PHP中file_get_contents函数抓取https地址出错的解决方法 [打印本页]

作者: admin    时间: 2023-12-5 11:23
标题: PHP中file_get_contents函数抓取https地址出错的解决方法
亲测,下面代码不用修改服务器的PHP.ini就能完美绕过HTTPS认证,远程抓取网页。
<?php
$stream_opts = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ]
];

$response = file_get_contents("https://XXX.XXX/",false, stream_context_create($stream_opts));
echo $response;
?>





欢迎光临 艾Q网 (http://js.iqi123.com/bbs/) Powered by Discuz! X3.4