Keyword Bulk query php self-write function code get keyword go hyperlink

Source: Internet
Author: User
1. Get keywords based on weights

Copy the Code code 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 the Code code 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

The above describes the keyword bulk query php self-write function code to get the keyword to hyperlink, including the keyword batch query content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    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.