织梦自带采集无法采集端口不为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(); } } |
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
☉本站的源码不会像其它下载站一样植入大量的广告。为了更好的用户体验以后坚持不打水印
☉本站只提供精品织梦源码,源码在于可用,不在多!!希望在这里找到你合适的。
☉本站提供的整站织梦程序,均带数据及演示地址。可以在任一源码详情页查看演示地址
☉本站所有资源(包括源码、模板、素材、特效等)仅供学习与参考,请勿用于商业用途。
☉如有其他问题,请加网站客服QQ进行交流。
- dedecms SQL注入漏洞 member/album_add.php 修复
- dedecms cookies泄漏导致SQL漏洞 /member/article_add
- Windows虚拟主机指定目录禁用脚本执行权限方法
- 西部数码虚拟主机设置禁止脚本执行权限
- 阿里云主机设置织梦程序禁止脚本执行权限及禁止写入
- dedecms织梦导致CPU峰值现象的解决办法
- 织梦程序网站被挂马或快照劫持终极解决办法
- 阿里云提醒/member/reg_new.php注入漏洞解决办法
- 织梦安全:更改plus名称
- 织梦栏目属性增加链接rel、nofollow和新窗口target
- 织梦问答模块PHP7报错解决方法
- dedecms解决移动端首页不自动更新问题