帝国cms教程

帝国cms如何采集https协议的网址内容

我的站长站 2023-12-28 人阅读

修改:/e/class/connect.php文件,在该文件最上面加上以下函数:

//获取https链接内容
function getHTTPS($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
}

找到ReadFiletext函数如下代码:

function ReadFiletext($filepath){
$filepath=trim($filepath);
$htmlfp=@fopen($filepath,"r");
//远程
if(strstr($filepath,"://"))
{
while($data=@fread($htmlfp,500000))
    {
$string.=$data;
}
}
//本地
else
{
$string=@fread($htmlfp,@filesize($filepath));
}
@fclose($htmlfp);
return $string;
}

改成:

function ReadFiletext($filepath){
$filepath=trim($filepath);
$htmlfp=@fopen($filepath,"r");
//远程
if(strstr($filepath,"https://")){
                return getHTTPS($filepath);
        }
if(strstr($filepath,"://"))
{
while($data=@fread($htmlfp,500000))
    {
$string.=$data;
}
}
//本地
else
{
$string=@fread($htmlfp,@filesize($filepath));
}
@fclose($htmlfp);
return $string;
}

自此可实现采集https开头的网页链接

相关专题
采集
采集
2022-03-03 1276

数据采集是网站运营与内容整理的常用技能,合理合规的采集方式能大幅提升内容整理效率。我的站长站整理各类实用采集工具、主流采集软件资源、零基础采集实操教程,讲...

帝国CMS教程标签