php抓取https的内容的代码
2017-03-28 16:14
381 查看
直接用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);
如果请求类型是
PHP Warning:
如果你说的实现https接口指的是让别人可以用https访问你,那么就需要用
复制代码 代码如下:
$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);
如果请求类型是
https,则只能用
curl了,前者会报(至少默认情况下):
PHP Warning:
file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?
如果你说的实现https接口指的是让别人可以用https访问你,那么就需要用
openssl生成公私钥,然后编译apache使支持
mod_ssl,然后再配置
httpd-ssl.conf文件,这些让系统管理员来做吧。。
相关文章推荐
- php抓取https的内容的代码
- 使用php方法curl抓取AJAX异步内容思路分析及代码分享
- php中抓取网页内容的代码
- PHP实现抓取HTTPS内容
- PHP实现抓取HTTPS内容的方法和错误处理
- PHP实现抓取HTTPS内容
- PHP如何抓取https内容?记录一下。
- PHP抓取HTTPS内容和错误处理的方法
- php 实现信息采集(网页内容抓取)程序代码
- php 抓取https内容
- php抓取https的内容
- PHP实现抓取HTTPS内容的方法和错误处理
- PHP实现抓取HTTPS内容的方法和错误处理
- 使用php方法curl抓取AJAX异步内容思路分析及代码分享
- PHP实现抓取HTTPS内容
- 【代码】获取https里面内容的方法和技巧使用php
- PHP 抓取网页图片并且另存为的实现代码
- php 论坛采集程序 模拟登陆,抓取页面 实现代码