校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 網站建設 > 建站知識 > DEDE采集時自動生成摘要和關鍵字

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];
}

重新上傳,大功告成。記得覆蓋的時候一定要備份哦。



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 西和县| 永定县| 东乡| 肥西县| 乡城县| 隆德县| 梁山县| 蕲春县| 澳门| 巴彦县| 安岳县| 荆州市| 浙江省| 北辰区| 莱州市| 大邑县| 屏东县| 田东县| 江口县| 咸丰县| 永济市| 广水市| 河曲县| 邢台县| 余庆县| 普宁市| 腾冲县| 香河县| 开封市| 萨迦县| 东明县| 德格县| 稷山县| 舒兰市| 盘山县| 余干县| 江津市| 遂宁市| 娄底市| 大同市| 山东省|