zoukankan      html  css  js  c++  java
  • PHP通过访客来路获取搜索关键词的方法

    <?php   
     class keyword{  
         public function getKeyword($referer){ 
             if(strpos($referer,"http://www.baidu.com")> -1 ){ 
                 $keyword = $this->getbaidukeyword($referer); 
             }else if(strpos($referer,"http://www.google.com")> -1 ){ 
                 $keyword = $this->getgooglekeyword($referer); 
             }else if(strpos($referer,"http://www.soso.com")> -1 ){ 
                 $keyword = $this->getsosokeyword($referer); 
             }else if(strpos($referer,"http://www.sogou.com")> -1 ){ 
                 $keyword = $this->getsogoukeyword($referer); 
             } 
              
             return $keyword; 
         }      
         //由来路取得百度关键词 
         private function getbaidukeyword($str){ 
             $s = strpos($str,'wd='); 
             if($s>-1){ 
                 $str = substr($str,$s+3); 
                 $e = strpos($str,'&'); 
                 if($e>-1){ 
                     $str = substr($str,0,$e); 
                 } 
                 $str = rawurldecode($str); 
             } 
             return $str; 
         } 
         //获得谷歌关键词 
         private function getgooglekeyword($str){ 
             $s = strpos($str,'&q='); 
             if($s>-1){ 
                 $str = substr($str,$s+3); 
                 $e = strpos($str,'&'); 
                 if($e>-1){ 
                     $str = substr($str,0,$e); 
                 } 
                 $str = rawurldecode($str); 
             } 
             return $str; 
         } 
         //获得SOSO关键词 
         private function getsosokeyword($str){ 
             $s = strpos($str,'?w='); 
             if($s>-1){ 
                 $str = substr($str,$s+3); 
                 $e = strpos($str,'&'); 
                 if($e>-1){ 
                     $str = substr($str,0,$e); 
                 } 
                 $str = rawurldecode($str); 
             }else{ 
                 $s = strpos($str,'&w='); 
                 if($s>-1){ 
                     $str = substr($str,$s+3); 
                     $e = strpos($str,'&'); 
                     if($e>-1){ 
                         $str = substr($str,0,$e); 
                     } 
                     $str = rawurldecode($str); 
                 } 
             } 
             return $str; 
         } 
         //获得sogou关键词 
         private function getsogoukeyword($str){ 
             $s = strpos($str,'query='); 
             if($s>-1){ 
                 $str = substr($str,$s+6); 
                 $e = strpos($str,'&'); 
                 if($e>-1){ 
                     $str = substr($str,0,$e); 
                 } 
                 $str = rawurldecode($str); 
             } 
             return $str; 
         } 
     }
    ?>
    

      

  • 相关阅读:
    23种设计模式
    <转>企业应用架构 --- 分层
    <转>C/S架构分析
    Decorator 模式转载
    2019-10-24 体检结果备查,降甘油三脂药物
    Entity Framework Core 文档 & Core Web API 文档
    MSSQLLocalDB 微软本地数据库,pk SQLlite
    InstallWatch Pro
    学习 skoruba/ IdentityServer4.Admin 完整版
    无代码与低代码开发平台,云+本地,阿里/腾讯
  • 原文地址:https://www.cnblogs.com/rnckty/p/4106259.html
Copyright © 2011-2022 走看看