php抓取https的内容的代码
更新时间:2010年04月06日 21:22:38 作者:
有时候需要获取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);
复制代码 代码如下:
$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);
相关文章
PHP+HTML+JavaScript+Css实现简单爬虫开发
这篇文章主要为大家详细介绍了PHP+HTML+JavaScript+Css实现简单爬虫开发,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2016-03-03安装apache2.2.22配置php5.4(具体操作步骤)
本篇文章是对安装apache2.2.22配置php5.4的具体操作步骤进行了详细的分析介绍,需要的朋友参考下2013-06-06
最新评论