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

主頁 > 網站建設 > 建站知識 > 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
主站蜘蛛池模板: 游戏| 德化县| 晋州市| 阿克苏市| 皋兰县| 新乐市| 谢通门县| 双鸭山市| 广灵县| 蚌埠市| 伊金霍洛旗| 罗田县| 中江县| 潜江市| 亳州市| 安顺市| 辽宁省| 旅游| 营口市| 钟祥市| 兴海县| 阜新市| 辽中县| 深泽县| 彝良县| 玉树县| 安阳市| 舞钢市| 汾西县| 康平县| 雷波县| 泗阳县| 太湖县| 静乐县| 衡阳县| 南充市| 万荣县| 通河县| 顺平县| 泽州县| 伽师县|