1. Get keywords based on weight
Copy the code The code is as follows:
function getkey($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 = @iplode('', file("http:// keyword.discuz.com/related_kw.html?title=$contents&ics=gbk&ocs=gbk"));
preg_match_all("/
for($i=0;$i<5;$i++){
$key=$key.$out[$i][2];
if($out[$i][2])$key=$key.",";
}
return $key;
}
//$contents is the article you want to get the keyword
Copy the code The 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->plaintext;//Text in the link;
$link ->outertext = $text;
}
$now_content = $html->save();
}
//preg_replace("/(.*?) /i","${1}", $content); You can also use regular expressions like this
The above introduces the keyword batch query PHP self-written function code to obtain keywords and remove hyperlinks, including the content of keyword batch query. I hope it will be helpful to friends who are interested in PHP tutorials.