Function steps for automatically extracting keyword seo-optimized website content from php

Source: Internet
Author: User
In php, the keyword is automatically extracted from the document content. seo optimizes the website functions. Using the basic conditions of discuz, the keyword is automatically extracted from the article content. in this way, the function method 1 of the link in the website is optimized: the keywords extracted in this method are closer to functiongetkey ($ contents) {// $ rows = stri php, which automatically extracts the keyword of the article content. the Function Method of seo to optimize the website

Use the basic conditions of discuz to automatically extract keywords from the document content, and then optimize the function method of the website chain. Method 1: The extracted keywords are relatively close

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("/ (.*)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; }
?
Method 2: The extracted keywords are slightly different from those above.
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("/
 
  (.*)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; }
 
? Haikou? Http://www.souhaikou.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.