zoukankan      html  css  js  c++  java
  • php中获取网站访客来源的关键词方法

    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;
    }
    
    }
    ?>
  • 相关阅读:
    LVS-三种负载均衡方式比较
    keepalived和heartbeat区别
    vmware-question
    SQL Server MYSQL 检查点的好处
    MYSQL 引擎的情况
    MYSQL 关闭服务的过程
    SQL Server 行的删除与修改-------------(未完待续P222 deep SQL Server 222 )
    SQL Server一些重要视图 1
    SQL Server 查看数据页面
    SQL Server 向堆表中插入数据的过程
  • 原文地址:https://www.cnblogs.com/wuheng1991/p/5179872.html
Copyright © 2011-2022 走看看