百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>织梦CMS教程> dedecms织梦自带采集无法采集端口不为80的网址错误解决方法
分享文章到:

dedecms织梦自带采集无法采集端口不为80的网址错误解决方法

发布时间:02/09 来源:未知 浏览: 关键词:

织梦采集,一般用不到采集网址有端口的情况,少数有端口的网址就无法采集了。总结了下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

01 Array
02   (
03   [0] => Array
04   (
05   [title] => 讲座回放|施奠东—西湖,世界风景园林的
08   )
09   [1] => Array
10   (
11   [title] => 喜报|恭贺我院2019年度西湖杯荣获佳绩!
14   )
15   [2] => Array
16   (
17   [title] => 讲座预告|西湖——世界风景园林的杰出范
20   )
21   [3] => Array
22   (
23   [title] => 讲座回放|胡理琛—西湖七十年流变忆胜
26   )
27   [4] => Array
28   (
29   [title] => 讲座回放|彭嘉恒—“南师、禅及其在西方
32   )
33   [5] => Array
34   (
35   [title] => 讲座预告|胡理琛—西湖七十年流变忆胜
38   )
39   )

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

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

  在include/dedehtml2.class.php

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

image.png

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

  付上代码:

01 function SetSource(&$html, $url = '', $linktype='')
02   {
03   $this->__construct();
04   $this->CAtt = new DedeAttribute2();
05   $url = trim($url);
06   $this->SourceHtml = $html;
07   $this->BaseUrl = $url;
08   //判断文档相对于当前的路径
09   $urls = @parse_url($url);
10   $port=$urls['port']=='80'?'':':'.$urls['port'];//lyy 为80时候可以省略,否则就加上
11   $this->HomeUrl = $urls['host'].$port;
12   $this->BaseUrlPath = $this->HomeUrl.$urls['path'];
13   $this->BaseUrlPath = preg_replace("/\/([^\/]*)\.(.*)$/","/",$this->BaseUrlPath);
14   $this->BaseUrlPath = preg_replace("/\/$/",'',$this->BaseUrlPath);
15   if($linktype!='')
16   {
17   $this->GetLinkType = $linktype;
18   }
19   if($html != '')
20   {
21   $this->Analyser();
22   }
23   }

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

相关文章

共有89人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板