织梦采集,dede无法采集端口不为80的网址错误解决

织梦采集,一般用不到采集网址有端口的情况,少数有端口的网址就无法采集了。总结了下dede无法采集端口不为80的网址错误解决:

问题描述,当采集的网址后代端口时(为防止有推广嫌疑就把网址换成xxx了。):

测试采集网址:http://www.xxx.com:89/index.php/main/news/index.html?channel_id=104&page=1

获取的列表测试信息网址是不带端口的结果是不带端口的数组集合:

测试的列表网址: http://www.xxx.com:89/index.php/main/news/index.html?channel_id=104&page=1
Array
(
    [0] => Array
        (
            [title] => 讲座回放|施奠东—西湖,世界风景园林的
            [link] => http://www.xxx.com/index.php/main/news/15529.html
            [image] => http://www.xxx.com/uploadfiles/articles/20190528/15529.png
        )

    [1] => Array
        (
            [title] => 喜报|恭贺我院2019年度西湖杯荣获佳绩!
            [link] => http://www.xxx.com/index.php/main/news/15528.html
            [image] => http://www.xxx.com/uploadfiles/articles/20190522/15528.jpg
        )

    [2] => Array
        (
            [title] => 讲座预告|西湖——世界风景园林的杰出范
            [link] => http://www.xxx.com/index.php/main/news/15526.html
            [image] => http://www.xxx.com/uploadfiles/articles/20190516/15526.jpg
        )

    [3] => Array
        (
            [title] => 讲座回放|胡理琛—西湖七十年流变忆胜
            [link] => http://www.xxx.com/index.php/main/news/15524.html
            [image] => http://www.xxx.com/uploadfiles/articles/20190513/15524.png
        )

    [4] => Array
        (
            [title] => 讲座回放|彭嘉恒—“南师、禅及其在西方
            [link] => http://www.xxx.com/index.php/main/news/15518.html
            [image] => http://www.xxx.com/uploadfiles/articles/20190507/15518.png
        )

    [5] => Array
        (
            [title] => 讲座预告|胡理琛—西湖七十年流变忆胜
            [link] => http://www.xxx.com/index.php/main/news/15516.html
            [image] => http://www.xxx.com/uploadfiles/articles/20190430/15516.jpg
        )

)

这样显然得到的网址是错误的。根本无法访问,也就无法采集了。

经过一番查找,原来是dede 设置HTML的内容和来源网址 的函数问题,漏写端口判断了。

include/dedehtml2.class.php

function SetSource 函数里大概79行加上红框里的内容:

再测试一下。ok 了,这样网址就可以正常打开,采集到了。

付上代码:

function SetSource(&$html, $url = '', $linktype='')
    {
        $this->__construct();
        $this->CAtt = new DedeAttribute2();
        $url = trim($url);
        $this->SourceHtml = $html;
        $this->BaseUrl = $url;
        //判断文档相对于当前的路径
        $urls = @parse_url($url);
        $port=$urls['port']=='80'?'':':'.$urls['port'];//lyy 为80时候可以省略,否则就加上
        $this->HomeUrl = $urls['host'].$port;
        $this->BaseUrlPath = $this->HomeUrl.$urls['path'];
        $this->BaseUrlPath = preg_replace("/\/([^\/]*)\.(.*)$/","/",$this->BaseUrlPath);
        $this->BaseUrlPath = preg_replace("/\/$/",'',$this->BaseUrlPath);
        if($linktype!='')
        {
            $this->GetLinkType = $linktype;
        }
        if($html != '')
        {
            $this->Analyser();
        }
    }

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北方的刀郎

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值