基於discuz線上分詞批量優化Dedecms文章關鍵字

來源:互聯網
上載者:User
關鍵字 discuz 關鍵字優化

仲介交易 HTTP://www.aliyun.com/zixun/aggregation/6858.html">SEO診斷 淘寶客 雲主機 技術大廳

dedecms本身自帶tag(keywords)提取功能,但分詞總是不夠精確。 當然,對於日更新十數篇且對seo精確執行的使用者來說,手工輸入能更好的控制。 但對於主題比較寬泛、內容更新量大的使用者來說,dede split是不大完美的。

discuz線上分詞是一個線上免費的提詞介面。 後有數十萬中文論壇、supsite使用者,對於語境、細胞詞庫的完善有更多的資料。 這個小程式是基於discuz線上分詞批量更新已發內容的keywords(tag),如果資料量大(大於5萬)的或者虛擬主機使用者的話,最好環境搭到本地。 速度會快一點。

使用方法,cms安裝目錄,新建c.php,拷入以下內容,自己對應編碼用notepad設置相應gbk或utf8。 運行 yourwebsite/c.php?id=1

<?php
require_once(dirname(__FILE__).」 /include/common.inc.php」);

$id = isset($id) && is_numeric($id) ? $id : 0;

for ($a=$id; $a<$id+10; $a++){

$row = $dsql->GetOne(」 SELECT arc.title,tp.body FROM `@__archives` arc LEFT JOIN `@__addonarticle` tp ON arc.id=tp.aid where arc.id=’$a’ 「);
if(is_array($row))
{
$title = $row['title'];
$body = $row['body'];
$keywords=zhgetkey($title.$body);
$dsql->ExecuteNoneQuery(」 Update `@__archives` set keywords=’$keywords’ where id=’$a’ 「);
echo $a.’:’.$keywords.’ <br />’;
}
}

if ($a>80000){break;}

echo 「<script>」;
echo 「setTimeout(\」location.replace(‘c.php?id=$a’)\」,0)」;
echo 「</script>」;

function zhgetkey($contents){
$rows = strip_tags($contents);
$arr = array(‘ ‘,’ ‘,」\s」, 「\r\n」, 「\n」, 「\r」, 「\t」, 「>」, 「「」, 「」」,」<br />」);
$qc_rows = str_replace($arr, 」, $rows);
if(strlen($qc_rows)>2400){
$qc_rows = substr($qc_rows, ’0′, ’2400′);
}
$data = @implode(」, file(「HTTP://keyword.discuz.com/related_kw.html?title=$qc_rows&ics=gbk&ocs=gbk」));
preg_match_all(「/<kw>(.*)A\[(.*)\]\](.*)><\/kw>/」,$data, $out, PREG_SET_ORDER);
$key=」";
for($i=0;$i<5;$i++){
$key=$key.$out[$i][2];
if($out[$i][2])$key=$key.」,」;
}
return $key;
}

function cutstr_html($string, $sublen)

{

$string = strip_tags($string);

$string = preg_replace (‘/\n/is’, 」, $string);

$string = preg_replace (‘/ | /is’, 」, $string);

$string = preg_replace (‘/&nbsp;/is’, 」, $string);

preg_match_all(「/[\x01-\x7f]|[ \xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]| [\xe1-\xef] [\x80-\xbf] [\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]| [\xf1-\xf7] [\x80-\xbf] [\x80-\xbf] [\x80-\xbf]/」, $string, $t_string);

if(count($t_string[0]) – 0 > $sublen) $string = join(」, array_slice($t_string[0], 0, $sublen)).」 ...」;

else $string = join(」, array_slice($t_string[0], 0, $sublen));

return $string;

}

?>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.