找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1005|回复: 0

[分享] DEDE采集时自动生成摘要和关键字

[复制链接]
发表于 2018-3-2 08:14:00 | 显示全部楼层 |阅读模式 来自 河南省郑州市
最近在学习织梦CMS的采集功能,在采集的过程我总是发现织梦5.6可以采集到内容,但不可自动生成摘要和关键字,关键字和摘要都是空的。感觉很遗憾,怎么办呢?
可能很多人都遇到了和我一样的问题,在论坛实在没找到好的解决办法,就自己动手去改改文件。废话不多说了。
下面是我的解决办法
比如我采集了网站:http://www.xx.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
  1. //自动分析关键字和摘要
  2. preg_match("/<meta[\s]+name=['"]keywords['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr);
  3. preg_match("/<meta[\s]+content=['"](.*)['"] name=['"]keywords['"]/isU",$this->tmpHtml,$inarr2);
  4. if(!isset($inarr[1]) && isset($inarr2[1]))
  5. {
  6. $inarr[1] = $inarr2[1];
  7. }
复制代码

用下面一段代码替换上面的
  1. //自动分析关键字和摘要
  2. preg_match("/<meta[\s]+name=['"]keywords['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr);
  3. preg_match("/<meta[\s]+content=['"](.*)['"] name=['"]keywords['"]/isU",$this->tmpHtml,$inarr2);
  4. preg_match("/<meta[\s]+name=keywords content=['"](.*)['"]/isU",$this->tmpHtml,$inarr3);
  5. if(!isset($inarr[1]) && isset($inarr2[1]))
  6. {
  7. $inarr[1] = $inarr2[1];
  8. }
  9. if(!isset($inarr[1]) && isset($inarr3[1]))
  10. {
  11. $inarr[1] = $inarr3[1];
  12. }
复制代码

改了上面的, 还有另一个地方需要修改的
  1. preg_match("/<meta[\s]+name=['"]description['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr);
  2. preg_match("/<meta[\s]+content=['"](.*)['"] name=['"]description['"]/isU",$this->tmpHtml,$inarr2);
  3. if(!isset($inarr[1]) && isset($inarr2[1]))
  4. {
  5. $inarr[1] = $inarr2[1];
  6. }
复制代码

用下面的代码替换掉上面的:
  1. preg_match("/<meta[\s]+name=['"]description['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr);
  2. preg_match("/<meta[\s]+content=['"](.*)['"] name=['"]description['"]/isU",$this->tmpHtml,$inarr2);
  3. preg_match("/<meta[\s]+name=description content=['"](.*)['"]/isU",$this->tmpHtml,$inarr3);
  4. if(!isset($inarr[1]) && isset($inarr2[1]))
  5. {
  6. $inarr[1] = $inarr2[1];
  7. }
  8. if(!isset($inarr[1]) && isset($inarr3[1]))
  9. {
  10. $inarr[1] = $inarr3[1];
  11. }
复制代码

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

发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;

如何回报帮助你解决问题的坛友,好办法就是点击帖子下方的评分按钮给对方加【金币】不会扣除自己的积分,做一个热心并受欢迎的人!

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 需要先绑定手机号

关闭

站长推荐上一条 /1 下一条

QQ|侵权投诉|广告报价|手机版|小黑屋|西部数码代理|飘仙建站论坛 ( 豫ICP备2022021143号-1 )

GMT+8, 2024-5-27 17:28 , Processed in 0.044223 second(s), 9 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表