基于Discuz在线分词的Dedecms文章关键词批量优化
  • 更新时间:2024-03-28 21:07:30
  • 网站建设
  • 发布时间:11个月前
  • 418

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

dedecms自带标签(关键词)提取功能(北京网站制作),但分词总是不够精确。当然,对于一天更新十篇以上,SEO精准执行的用户,手动输入可以更好的控制(高端网站建设)。但对于题材广泛、内容更新量大的用户来说,dede拆分并不完美。

discuz在线分词是一个在线免费的分词提示界面。中文论坛和suspite用户有几十万,上下文和单元格词库的完善有更多的数据。本小程序基于discuz在线分词,批量更新发布内容的关键词(标签)。如果数据量大(5万以上)或者虚拟主机用户,最好使用本地环境。会快一点。

l; background-clip: initial; background-color: transparent; background-position: initial initial; background-repeat: initial initial; ">  使用方法,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”, “rn”, “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;

 }

?>

我们专注高端建站,小程序开发、软件系统定制开发、BUG修复、物联网开发、各类API接口对接开发等。十余年开发经验,每一个项目承诺做到满意为止,多一次对比,一定让您多一份收获!

本文章出于推来客官网,转载请表明原文地址:https://www.tlkjt.com/web/13660.html

在线客服

扫码联系客服

3985758

回到顶部