首页 > php教程 > PHP源码 > 正文

php获取网站关键词

PHP中文网
发布: 2016-05-25 17:09:48
原创
1041 人浏览过

1. [代码]php代码              

<?php 
$_SERVER[&#39;HTTP_REFERER&#39;]=&#39;http://www.baidu.com/s?wd=http://www.php.cn/&#39;; 
echo save_www_iiwnet_com_keyword(&#39;http://www.baidu.com/s?wd=http://www.php.cn/&#39;,&#39;http://www.baidu.com/s?wd=http://www.php.cn/&#39;); 
function save_www_iiwnet_com_keyword($domain,$path){ 
 if(strpos($domain, &#39;google.com.tw&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;GOOGLE TAIWAN&#39;; 
  $keywords = urldecode($regs[1]); // google taiwan 
    } 
 if(strpos($domain,&#39;google.cn&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;GOOGLE CHINA&#39;; 
  $keywords = urldecode($regs[1]); // google china 
 } 
 if(strpos($domain,&#39;google.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;GOOGLE&#39;; 
  $keywords = urldecode($regs[1]); // google 
 }elseif(strpos($domain,&#39;baidu.&#39;)!==false && preg_match(&#39;/wd=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;BAIDU&#39;; 
        $keywords = urldecode($regs[1]); // baidu 
    }elseif(strpos($domain,&#39;baidu.&#39;)!==false && preg_match(&#39;/word=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;BAIDU&#39;; 
        $keywords = urldecode($regs[1]); // baidu 
    }elseif(strpos($domain,&#39;114.vnet.cn&#39;)!== false && preg_match(&#39;/kw=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;CT114&#39;; 
        $keywords = urldecode($regs[1]); // ct114 
    }elseif(strpos($domain,&#39;iask.com&#39;)!==false && preg_match(&#39;/k=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;IASK&#39;; 
        $keywords = urldecode($regs[1]); // iask 
    }elseif(strpos($domain,&#39;soso.com&#39;)!==false && preg_match(&#39;/w=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;SOSO&#39;; 
        $keywords = urldecode($regs[1]); // soso 
    }elseif(strpos($domain, &#39;sogou.com&#39;)!==false && preg_match(&#39;/query=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;SOGOU&#39;; 
        $keywords = urldecode($regs[1]); // sogou 
    }elseif(strpos($domain,&#39;so.163.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;NETEASE&#39;; 
        $keywords = urldecode($regs[1]); // netease 
    }elseif(strpos($domain,&#39;yodao.com&#39;)!== false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YODAO&#39;; 
        $keywords = urldecode($regs[1]); // yodao 
    }elseif(strpos($domain,&#39;zhongsou.com&#39;)!==false && preg_match(&#39;/word=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;ZHONGSOU&#39;; 
        $keywords = urldecode($regs[1]); // zhongsou 
    }elseif(strpos($domain,&#39;search.tom.com&#39;)!==false && preg_match(&#39;/w=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;TOM&#39;; 
        $keywords = urldecode($regs[1]); // tom 
    }elseif(strpos($domain,&#39;live.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSLIVE&#39;; 
        $keywords = urldecode($regs[1]); // MSLIVE 
    }elseif(strpos($domain, &#39;tw.search.yahoo.com&#39;)!==false && preg_match(&#39;/p=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YAHOO TAIWAN&#39;; 
        $keywords = urldecode($regs[1]); // yahoo taiwan 
    }elseif(strpos($domain,&#39;cn.yahoo.&#39;)!==false && preg_match(&#39;/p=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YAHOO CHINA&#39;; 
        $keywords = urldecode($regs[1]); // yahoo china 
    }elseif(strpos($domain,&#39;yahoo.&#39;)!==false && preg_match(&#39;/p=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YAHOO&#39;; 
        $keywords = urldecode($regs[1]); // yahoo 
    }elseif(strpos($domain,&#39;msn.com.tw&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSN TAIWAN&#39;; 
        $keywords = urldecode($regs[1]); // msn taiwan 
    }elseif(strpos($domain,&#39;msn.com.cn&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSN CHINA&#39;; 
        $keywords = urldecode($regs[1]); // msn china 
    }elseif(strpos($domain,&#39;msn.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSN&#39;; 
        $keywords = urldecode($regs[1]); // msn 
    } 
 return $keywords; 
}
登录后复制

                   

                   

相关标签:
php
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!