PHP教程:php抓取https的内容

2012 年 10 月 13 日8510

PHP教程:php抓取https的内容

http://www.enet.com.cn/eschool/2011年06月17日16:37来源:网页教学网作者:佚名

【文章摘要】PHP教程:php抓取https的内容

直接用file_get_contents,会报错;


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


错误:
程序代码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的方式是可以的:
程序代码$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);

点击阅读更多学院相关文章>>

责任编辑:杜铮

0 0