时间:2021-07-01 10:21:17 帮助过:5人阅读
利用discuz的基础条件实现文章内容自动提取关键字,进而优化网站内链的函数方法
方法一:此方法提取的关键字比较接近
function getkey($contents){ //
$rows = strip_tags($contents);
$arr = array(' ',' ',"\s", "\r\n", "\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("/
function getkey($contents){ $key = ''; $rows = strip_tags($contents); $arr = array(' ',' ',"\s", "\r\n", "\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=$contents&ics=gbk&ocs=gbk")); preg_match_all("/? 海口?http://www.souhaikou.com(.*)A\[(.*)\]\](.*)><\/kw>/",$data, $out, PREG_SET_ORDER); for($i=0;$i<5;$i++){ $key=$key.$out[$i][2]; if($out[$i][2])$key=$key.","; } return $key; }