function baiduKeyword($title,$num=5,$charset=”UTF-8″){
        $title=iconv($charset, “GB2312”, $title);
        preg_match_all(“|<div id=con>(.*)</div>|isU”,$w,$con);
        preg_match_all(“|<ul><li>(.*)</li><li><a target=_blank href=(.*)>(.*)</a></li><li><img src= height=6 width=(\d*) align=absmiddle vspace=5></li></ul>|isU”,$list,$content);
        $r=array_slice($c, 0, $num);   
        $result=implode(“,”, $r);
        $result=iconv(“GB2312”, $charset,$result);
        return $result;

//通过DZ获取文章关键字,输入标题和内容 即可返回5个关键字数组
function getTags($title,$content){

        $subjectenc = rawurlencode(strip_tags($title));
        $messageenc = rawurlencode(strip_tags(preg_replace(“/\[.+?\]/U”, ”,$content)));
        $subjectenc =substr($subjectenc,0,60);
        $data = @implode(”, file(“$subjectenc&content=$messageenc&ics=utf-8&ocs=utf-8&#8221;));
        $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);
                foreach($values as $valuearray) {
                        if($valuearray[‘tag’] == ‘kw’ || $valuearray[‘tag’] == ‘ekw’) {
                                $kw =trim($valuearray[‘value’]);       
                                $kws[] =$kw ;

        return $kws;


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: