當前位置:首頁 >  站長 >  搜索優(yōu)化 >  正文

基于discuz在線分詞批量優(yōu)化Dedecms文章關(guān)鍵詞

 2011-12-21 21:12  來源: 山西網(wǎng)絡(luò)營銷博客   我來投稿 撤稿糾錯

  域名預(yù)訂/競價,好“米”不錯過

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

discuz在線分詞是一個在線免費的提詞接口。后有數(shù)十萬中文論壇、supsite用戶,對于語境、細胞詞庫的完善有更多的數(shù)據(jù)。這個小程序是基于discuz在線分詞批量更新已發(fā)內(nèi)容的keywords(tag),如果數(shù)據(jù)量大(大于5萬)的或者虛擬主機用戶的話,最好環(huán)境搭到本地。速度會快一點。

使用方法,cms安裝目錄,新建c.php,拷入以下內(nèi)容,自己對應(yīng)編碼用notepad設(shè)置相應(yīng)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(“;));
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;

 }

?>

申請創(chuàng)業(yè)報道,分享創(chuàng)業(yè)好點子。點擊此處,共同探討創(chuàng)業(yè)新機遇!

相關(guān)文章

熱門排行

信息推薦