智慧建站平台,千套网站模板,免费随心选!

您现在的位置: 首页>>网站教程

phpcms v9 采集功能 不能用怎么办?

来源: 发布时间:2020-01-10热度:1509 ℃
phpcms v9 采集功能 不能用怎么办?无法采集https的网站内容主要是https不支持file_get_contents获取内容,所以可以考虑采用curl的方式获取。(需要开启curl,可以在···

phpcms v9 采集功能 不能用怎么办?

phpcms v9 采集功能 不能用怎么办?

无法采集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; 
    }
登录后复制

本文地址:http://ezhuoer.com