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

*Published:* 2023-12-29
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年12月29日，已超过 180天没有更新



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

```
//获取<a class="tag_link" href="https://www.xarjtc.com/tag/https" target="_blank" title="查看https此标签更多文章"><abbr title="">https</abbr></a>链接内容
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开头的网页链接。