网站建设

PC + 手机 + 微信网站 + 小程序 + APP,五端合一

当前位置:首页>新闻资讯>网站建设

基于discuz在线分词批量优化Dedecms文章关键词

时间:2025-04-06   访问量:1107

基于discuz在线分词批量优化Dedecms文章关键词

dedecms本身自带tag(keywords)提取功能(北京网站制作),但分词总是不够精确。当然,对于日更新十数篇且对seo精确执行的用户来说,手工输入能更好的控制(高端网站建设)。但对于主题比较宽泛、内容更新量大的用户来说,dede split是不大完美的。

discuz在线分词是一个在线免费的提词接口。后有数十万中文论坛、supsite用户,对于语境、细胞词库的完善有更多的数据。 这个小程序是基于discuz在线分词批量更新已发内容的keywords(tag),如果数据量大(大于5万)的或者虚拟主机用户的话,最好环境搭到本地。速度会快一点。

使用方法,cms安装目录,新建c.php,拷入以下内容,自己对应编码用notepad设置相应gbk或utf8。运行 yourwebsite/c.php?id=1

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.’
’;

}

}

if ($a>80000){break;}

echo “<script>”;

echo “setTimeout(”location.replace(‘c.php?id=$a’)”,0)”;

echo “”;

function zhgetkey($contents){

$rows = strip_tags($contents);

$arr = array(‘ ‘,’ ‘,”s”, “rn”, “n”, “r”, “t”, “>”, ““”, “””,”
”);

$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(“/(.*)A[(.*)]](.*)>/”,$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 (‘/ /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;

}

?>

上一篇:企业建网站在网页效果图中如何正确合理的搭配色彩

下一篇:企业做网站图像颜色

发表评论:

评论记录:

未查询到任何数据!

在线咨询

点击这里给我发消息 售前咨询专员

点击这里给我发消息 售后服务专员

在线咨询

免费通话

24小时免费咨询

请输入您的联系电话,座机请加区号

免费通话

微信扫一扫

微信联系
返回顶部