html5中文学习网

您的位置: 首页 > 网络编程 > PHP编程 » 正文

PHP教程:php抓取https的内容_PHP教程_编程技术

[ ] 已经帮助:人解决问题
dw8HTML5中文学习网 - HTML5先行者学习网

直接用file_get_contents,会报错;

photo 程序代码$url = (https://xxx.com");
file_get_contents($url);

错误:
photo 程序代码Warning: file_get_contents(https://xxx.com) [function.file-get-contents]: failed to open stream: No such file or directory in D:wampwwwgrabber_clientindex.php on line 3

用curl的方式是可以的:
photo 程序代码$url = (https://xxx.com);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
print_r($result);
?>

重点是以下两句:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
dw8HTML5中文学习网 - HTML5先行者学习网
dw8HTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助