手机
当前位置:查字典教程网 >编程开发 >php教程 >php抓取https的内容的代码
php抓取https的内容的代码
摘要:直接用file_get_contents,会报错;复制代码代码如下:$url=(https://xxx.com");file_get_con...

直接用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抓取https的内容的代码】相关文章:

php 字母大小写转换的方法

PHP文件读取功能的应用实例

最好用的JavaScript开发工具和代码编辑器

phpcms手机内容页面添加上一篇和下一篇

php中数据的批量导入(csv文件)

php遍历CSV类实例

php计数器的设计与实现第1/2页

一个完整的PHP类包含的七种语法说明

php实现的mongodb操作类

php编写批量生成不重复的卡号密码代码

精品推荐
分类导航