草根站长论坛's Archiver

阿祥 发表于 2008-7-18 15:04

利用php现成的函数,制作关键字密度查询

[font=NSimsun][code]   <?php?yx2DNtVB7e tb&\
    function str_exists($item,$key,$keyword){
Sq ~Yz}u          global $i;TZ6GP6U*E$`,y
         if(preg_match("/$keyword/i",$item)){
wRp3cIAQ1P           $i++;
2E_T GS'FQ          }:N[5Dv!b
        }
4Y,}#o/mC [9k9\,Gv         function clean_html($str){
Es]JL"M4sY         return preg_replace("/<\/[^>]+>|<[^\s]+\s|\'|\"|<[a-z]+>/i",'',$str);
9Sf{mh         }3_'v'v5EW_W
s[0G8Hd){
        function count_density($item,$key,$sum){sEz"N9H
                if($item>0)7LO7v8vd$R%j
          echo "
4aF P#W'l/Ab F,x)CT%x6X
$item times of $key, with the frequency of".number_format(($item/$sum)*100,2)."8MI_ ?"]([4cr

T]MPG a H!y^n "; } $site=$_POST['site']; if(strpos($site,'http://')===false){ $site="http://".$site; } $keyword=trim($_POST['keyword']); $str=file_get_contents($site); $str1=clean_html($str); $a1=str_word_count($str1,1,$keyword);//获得所有的英语单词 arsort($a1); $i=0; array_walk($a1,'str_exists',$keyword); $coo=count($a1); echo "$i times of $keyword,with the frequency of :".number_format(($i/$coo)*100,2).'%';
'cn#a tf-s:E
b&^`E(zJ!q ?>[/code][/font]ITQ N%n_
演示地址:[url=http://blog.zenme.org/demo/keyword_dentiry.php][color=#800080]http://blog.zenme.org/demo/keyword_dentiry.php[/color][/url]+~%]J;y!A@
有好的建议,欢迎跟我联系.QQ:628558

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.