menu 李昊天的个人博客
爬取自己博客报错 file_get_contents(): SSL operation failed with code 1.
1433 浏览 | 2021-11-16 | 分类:服务器部署 | 标签:PHP

今天用一个爬虫工具爬取自己博客的时候报了一个ssl的错误

出现上面的原因,属于SSL证书不一致造成

解决方法是

修改file_get_contents 函数

$getJson =file_get_contents(staticFiles('assets/json/owo.json',1), false,stream_context_create([
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
    ]
]));

原内容

  $getJson =file_get_contents(staticFiles('assets/json/owo.json',1));

还百度到了一种解决方法是安装根证书没尝试记录一下

yum install ca-certificates
知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

发表评论

email
web

全部评论 (暂无评论)

info 还没有任何评论,你来说两句呐!