### [phpcms无法采集怎么办](https://www.prosaas.cn/article/4260) **Published:** 2019-12-28T02:06:31 **Author:** 5201314 **Excerpt:** phpcms无法采集怎么办?无法采集https的网站内容主要是https不支持file_get_content… **![](//zhiqipro.oss-cn-beijing.aliyuncs.com/2023/12/20231212122755616.jpg)** **phpcms无法采集怎么办?** 无法采集https的网站内容主要是https不支持file\_get\_contents获取内容,所以可以考虑采用curl的方式获取。(需要开启curl,可以在pathinfo里边查看) (1)打开phpcms\\modules\\collection\\classes\\collection.class.php 在类里边添加新函数: protected static function curl\_request($url){ if (!function\_exists('curl\_init')) { throw new Exception('server not install curl'); } $ch = curl\_init(); curl\_setopt($ch, CURLOPT\_URL,$url); curl\_setopt($ch, CURLOPT\_HEADER,0); curl\_setopt($ch, CURLOPT\_RETURNTRANSFER,1);//禁止调用时就输出获取到的数据 curl\_setopt($ch, CURLOPT\_FOLLOWLOCATION,1); curl\_setopt($ch, CURLOPT\_SSL\_VERIFYPEER,false); curl\_setopt($ch, CURLOPT\_SSL\_VERIFYHOST,false); $result = curl\_exec($ch); curl\_close($ch); return $result; } (2)找到函数function get\_htm把该函数 protected static function get\_html($url, &$config) { if (!empty($url) && $html = @file\_get\_contents($url)) { if ($syscharset != $config\['sourcecharset'\] && $config\['sourcetype'\] != 4) { $html = iconv($config\['sourcecharset'\], CHARSET.'//TRANSLIT//IGNORE', $html); } return $html; } else { return false; } } 改成 protected static function get\_html($url, &$config) { if(substr(trim($url),0, 5) == "https"){ $html = @self::curl\_request($url); }else{ $html = @file\_get\_contents($url); } if (!empty($url) && $html) { if ($syscharset != $config\['sourcecharset'\] && $config\['sourcetype'\] != 4) { $html = iconv($config\['sourcecharset'\], CHARSET.'//TRANSLIT//IGNORE', $html); } return $html; } else { return false; } } 然后保存即可获取,测试结果 ![](//zhiqipro.oss-cn-beijing.aliyuncs.com/2023/12/20231212122755836.png) 不知道是否还有其他bug,欢迎留言反馈! PHP中文网,大量的免费PHPCMS教程,欢迎在线学习! 以上就是phpcms无法采集怎么办的详细内容,更多请关注知企PROSAAS其它相关文章! **Categories:** PHPCMS ---