• 全国400电话网上服务平台
    强大号码库资源任选,方便,快捷,快速开通。
    咨询热线:400-1100-266  

    DEDE采集时自动生成摘要和关键字
    POST TIME:2020-03-28 23:54

    最近在学习织梦CMS的采集功能,在采集的过程我总是发现织梦5.6可以采集到内容,但不可自动生成摘要和关键字,关键字和摘要都是空的。感觉很遗憾,怎么办呢?

    可能很多人都遇到了和我一样的问题,在论坛实在没找到好的解决办法,就自己动手去改改文件。废话不多说了。

    下面是我的解决办法

    比如我采集了网站:http://www.genban.org

    首页的meta代码是:

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>一条龙建站 - 建站服务,建站教程,新云建站教程,织梦建站教程,CMS建站教程</title>
    <meta name="description" content="一个综合建站教程、建站经验交流、织梦CMS建站技巧、CMS建站模板的站长教程网。" />
    <meta name="keywords" content="建站教程,织梦建站教程,CMS建站教程" />

    如果用织梦模板的采集的时候就没有办法自动获取description和keywords的值的。

    1、修改 include/dedecollection.class.php

    //自动分析关键字和摘要
    preg_match("/<meta[s]+name=['&;]keywords['&;] content=['&;](.*)['&;]/isU",$this->tmpHtml,$inarr);
    preg_match("/<meta[s]+content=['&;](.*)['&;] name=['&;]keywords['&;]/isU",$this->tmpHtml,$inarr2);
    if(!isset($inarr[1]) && isset($inarr2[1]))
    {
    $inarr[1] = $inarr2[1];
    }

    用下面一段代码替换上面的

    //自动分析关键字和摘要
    preg_match("/<meta[s]+name=['&;]keywords['&;] content=['&;](.*)['&;]/isU",$this->tmpHtml,$inarr);
    preg_match("/<meta[s]+content=['&;](.*)['&;] name=['&;]keywords['&;]/isU",$this->tmpHtml,$inarr2);
    preg_match("/<meta[s]+name=keywords content=['&;](.*)['&;]/isU",$this->tmpHtml,$inarr3);
    if(!isset($inarr[1]) && isset($inarr2[1]))
    {
    $inarr[1] = $inarr2[1];
    }
    if(!isset($inarr[1]) && isset($inarr3[1]))
    {
    $inarr[1] = $inarr3[1];
    }

    改了上面的, 还有另一个地方需要修改的

    preg_match("/<meta[s]+name=['&;]description['&;] content=['&;](.*)['&;]/isU",$this->tmpHtml,$inarr);
    preg_match("/<meta[s]+content=['&;](.*)['&;] name=['&;]description['&;]/isU",$this->tmpHtml,$inarr2);
    if(!isset($inarr[1]) && isset($inarr2[1]))
    {
    $inarr[1] = $inarr2[1];
    }

    用下面的代码替换掉上面的:

    preg_match("/<meta[s]+name=['&;]description['&;] content=['&;](.*)['&;]/isU",$this->tmpHtml,$inarr);
    preg_match("/<meta[s]+content=['&;](.*)['&;] name=['&;]description['&;]/isU",$this->tmpHtml,$inarr2);
    preg_match("/<meta[s]+name=description content=['&;](.*)['&;]/isU",$this->tmpHtml,$inarr3);
    if(!isset($inarr[1]) && isset($inarr2[1]))
    {
    $inarr[1] = $inarr2[1];
    }
    if(!isset($inarr[1]) && isset($inarr3[1]))
    {
    $inarr[1] = $inarr3[1];
    }

    重新上传,大功告成。记得覆盖的时候一定要备份哦。

    
    关于我们 | 付款方式 | 建站知识 | 增值服务 | 网站模板
    Copyright © 2003-2016
    时间:9:00-21:00 (节假日不休)
    版权所有:巨人网络(扬州)科技有限公司
    总部地址:江苏省信息产业基地11号楼四层
    《增值电信业务经营许可证》 苏B2-20120278
    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信

    微信号已复制,请打开微信添加咨询详情!