The php function obtains the keyword intercepted by the hot list.

Source: Internet
Author: User
I don't want to talk about it myself. I can turn back to the plug-in to make some bad websites. a website contains the top field of the Baidu Hot list and makes a good description of the tag. Then, you can use the search engine to search for the content of an article.

I don't want to talk about it myself. I can turn back to the plug-in to make some bad websites. a website contains the top field of the Baidu Hot list and makes a good description of the tag. Then, you can use the search engine to search for the content of an article.

/**
* @ Author: ZhangQingYue-Motorcom
* @ Description: returns the current baidu Hot List for seo.
* @ FirstCreatDate: 2010-4-23
* @ Param: title-title
* @ Param: content-body
*/
Function getHotKeysByBaidu ($ title, $ charset = "UTF-8 ″){
$ Title = iconv ($ charset, "GB2312", $ title );
$ W = file_get_contents ('http: // top.baidu.com /');
// Die ($ w );
// Obtain the list
Preg_match_all ('| (. *) | isU', $ w, $ con );
$ List = $ con [1] [0];
Return $ list;
}
/**
* @ Author: ZhangQingYue-Motorcom
* @ Description: Title. Five keywords are returned for article analysis.
* @ FirstCreatDate: 2010-4-23
* @ Param: title-title
* @ Param: content-body
*/
Function getTags ($ title, $ content ){
$ Subjectenc = rawurlencode (strip_tags ($ title ));
$ Messageenc = rawurlencode (strip_tags (preg_replace ("/\ [. +? \]/U ",", $ content )));
$ Subjectenc = substr ($ subjectenc, 0, 60 );
$ Messageenc = substr ($ messageenc );
$ Data = @ implode (", file (" http://keyword.discuz.com/related_kw.html? Title = $ subjectenc & content = $ messageenc & ics = UTF-8 & ocs = utf-8 ");
$ Kws = array ();
If ($ data ){
$ Parser = xml_parser_create ();
Xml_parser_set_option ($ parser, XML_OPTION_CASE_FOLDING, 0 );
Xml_parser_set_option ($ parser, XML_OPTION_SKIP_WHITE, 1 );
Xml_parse_into_struct ($ parser, $ data, $ values, $ index );
Xml_parser_free ($ parser );
Foreach ($ values as $ valuearray ){
If ($ valuearray ['tag'] = 'kw '| $ valuearray ['tag'] = 'ekw '){
$ Kw = trim ($ valuearray ['value']);
$ Kws [] = $ kw;
}
}
}
Return $ kws;
}
/**
* @ Author: ZhangQingYue-Motorcom
* @ Description: Unix timestamp returns the time difference between the document storage time and the current time.
* @ FirstCreatDate: 2010-4-23
* @ Param: posttime-Unix timestamp of the release time
*/
Function getTimesAgo ($ posttime)
{
Echo $ now = time ();
$ Text = "";
$ Diff = (int) abs ($ now-$ posttime );
If ($ diff <= 3600 ){
$ Mins = round ($ diff/60 );
If ($ mins <= 1 ){
$ Mins = 1;
}
// Var_dump ($ mins );
$ Mins = sprintf ("posted before % s Minutes", $ mins );
Return $ mins;
// Echo $ text;
} Else
If ($ diff <= 86400) & ($ diff> 3600 )){
$ Hours = round ($ diff/3600 );
If ($ hours <= 1 ){
$ Hours = 1;
}
$ Hours = sprintf ("posted before % s hours", $ hours );
Return $ hours;
} Elseif ($ diff >=86400 ){
$ Days = round ($ diff/86400 );
If ($ days <= 1 ){
$ Days = 1;
}
// Formatted time to return the date taotao. that's exactly what we do. it's just a js version.
$ Days = sprintf ("posted before % s days", $ days );
Return $ days;
}
}

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.