设为首页 加入收藏

TOP

DedeCms采集没有自动生成摘要和关键字的解决办法
2011-08-21 04:35:58 来源: 作者: 【 】 浏览:366次 评论:0
DedeCms采集没有自动生成摘要和关键字的解决办法 - CMS教程 - 建站程序 - 烈火网
  

DedeCms采集没有自动生成摘要和关键字的解决办法

织梦5.6采集到了内容,可没有自动生成摘要和关键字,关键字和摘要都是空的。

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

下面是我的解决办法

比如我采集了网站:http://www.52iphone8.com

首页的meta代码是:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>iphone苹果中文网</title>
<meta name=description content="苹果iPhone手机中文官网,为您提供苹果iPhone 4代手机最新报价,同时包括苹果iPhone手机图片、苹果iPhone手机参数、苹果iPhone手机主题、苹果iPhone手机软件、苹果iPhone手机游戏、苹果iPhone手机评测行情、苹果iphone视频、苹果iphone铃声、苹果iPhone手机论坛、苹果iPhone手机下载等信息。" />
<meta name=keywords content="苹果手机,iphone,苹果中文网,苹果手机官网,iphone4代,苹果iphone,iPhone手机,苹果手机报价,图片,论坛,游戏,电影,主题,铃声,铃声,下载,软件,应用" />

如果用dedecms的采集的时候就没有办法自动获取description和keywords的值的。
大家注意到了这段代码和其它网站的区别了没??
<meta name=description content=... />
<meta name=keywords content=... />
就是name="description" 和 name="keywords" 少了双引号""
这个可能是dedecms中自动分析关键字和摘要的一个bug吧,没有考虑到<meta name=keywords content ='' />这种情况!
采集的选项里面也没有自己填写关键字和摘要的选项。那我只能自己动手修改文件了。
1、修改 include/dedecollection.class.php

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
//自动分析关键字和摘要
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];
}

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

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
//自动分析关键字和摘要
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];
}

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

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
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];
}

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

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
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];
}

重新上传,大功告成。记得覆盖的时候一定要备份哦。感谢Iphone苹果中文网的投递,文章出处:http://www.52iphone8.com

    100% (4)
    0% (0)
    Tag标签:DEDECMS 关键字 文章摘要 dedecms采集 
    本文编辑:柳絮随风
    更多..

    网友评论

    发表评论(拉取统计信息……)
    用户名: 验证码:点击更换
    超过 人围观,
    您看到此篇文章时的感受是:
    Tags: 责任编辑:administrator
    】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
    分享到QQ空间
    分享到: 
    上一篇DedeCms 5.7 无法生成首页的解决.. 下一篇DedeCms增加cookie有效域,会员中..

    评论

    帐  号: 密码: (新用户注册)
    验 证 码:
    表  情:
    内  容:

    相关栏目

    最新文章

    图片主题

    热门文章

    推荐文章

    相关文章

    广告位