[织梦CMS教程] DEDE采集时自动生成摘要和关键字

[复制链接]
查看1563 | 回复8 | 2019-2-12 23:59:46 | 显示全部楼层 |阅读模式
最近在学习织梦dedeCMS的采集功能,在采集的过程我总是发现织梦织梦dedeCMS5.6可以采集到内容,
但不可自动生成摘要和关键字,关键字和摘要都是空的。感觉很遗憾,怎么办呢?
可能很多人都遇到了和我一样的问题,在论坛实在没找到好的解决办法,就自己动手去改改文件。废话不多说了。 下面是我的解决办法 比如我采集了网站:http://www.baidu.com 首页的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]; 
}
重新上传,大功告成。记得覆盖的时候一定要备份哦。从0基础开始学习织梦dedecms建站,分享全套的织梦dedecms网站搭建教程、织梦安装使用教程。 汇聚了最全、最新的织梦cms建站教程。包含dedecms建站、仿站教程;dedecms系统使用常见问题;主题插件推荐下载等!欢迎学习!
回复

使用道具 举报

hedeafmz28 | 2020-11-11 04:27:25 | 显示全部楼层
加油!悟空源码,继续努力!支持你!
回复

使用道具 举报

加菲猫419 | 2021-3-3 16:02:03 | 显示全部楼层
找了很多地方都不能下载,终于在悟空源码找到了
回复

使用道具 举报

网路游民甲厝 | 2021-7-2 22:09:27 | 显示全部楼层
有情怀的站啊,爱了
回复

使用道具 举报

poney | 2021-9-20 16:08:02 | 显示全部楼层
加油!悟空源码,继续努力!支持你!
回复

使用道具 举报

甜心猫舍 | 2023-5-15 06:55:20 | 显示全部楼层
这个下载站资源真齐全
回复

使用道具 举报

是哒hhh | 2024-2-2 05:01:07 | 显示全部楼层
谢谢楼主发布的资源下载,帮助我不少
回复

使用道具 举报

爱喝水的姑娘 | 2024-3-6 21:54:46 | 显示全部楼层
谢谢楼主发布的资源下载,帮助我不少
回复

使用道具 举报

索支较 | 2024-3-12 10:38:04 | 显示全部楼层
站长真良心,这么大的资源站都是免费下载
回复

使用道具 举报

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

本版积分规则