1. Get keywords based on weights
Copy CodeThe code is as follows:
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= $contents &ICS=GBK&OCS=GBK "));
Preg_match_all ("/ (.*) 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;
}
$contents for the article you want to get the keyword
2. Remove the hyperlinks in the article simple, concise
Copy CodeThe code is as follows:
function Get_new_content ($content) {
Include (".. /simple_html_dom.php ");
$html = str_get_html ($content);
$a _href = $html->find (' a ');
foreach ($a _href as $link) {
$text = $link The text in the->plaintext;//link;
$link->outertext = $text;
}
$now _content = $html->save ();
}
Preg_replace ("/(. *?) <\/a>/i "," \${1} ", $content); It's also possible to use the regular
http://www.bkjia.com/PHPjc/321115.html www.bkjia.com true http://www.bkjia.com/PHPjc/321115.html techarticle 1. Get the keyword copy code code according to the Weight: function Getkey ($contents) {$rows = Strip_tags ($contents); $arr = Array (",", "\s", "\ r \ n", "\ n "," \ r "," \ T "," "," "," "); ..