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) & gt; 2400 ){
$ Qc_rows = substr ($ qc_rows, '0', '123 ');
}
$ Data = @ implode ('', file (" http://keyword.discuz.com/related_kw.html? Title = $ contents & ics = gbk & ocs = gbk "));
Preg_match_all ("/<kw> (. *) \[(. *) \] (. *)> <\/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 the article for you to get the keyword
2. Removing hyperlinks in the article is simple and 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-> plaintext; // text in the link;
$ Link-> outertext = $ text;
}
$ Now_content = $ html-> save ();
}
// Preg_replace ("/<a. *?> (.*?) <\/A>/I "," \ $ {1} ", $ content); you can also use regular expressions.