PHP通过访客来路获取搜索关键词的方法
来源:
时间:2024-08-17 13:15:45
热度:
PHP通过访客来路获取搜索关键词的方法【专家解说】:<?php class keyword{ public function getKeyword($referer)
【专家解说】:<?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; } } ?>
上一篇:谁知道江淮电动汽车不能拉滴滴快车
-
毕业论文,计数器的设计方法探讨,谁写一下,谢谢!!!2024-08-17
-
未来路与石化路交叉口怎么坐车?2024-08-17
-
插IC卡的燃气表,最下面是水平插IC卡的,上面是液晶显示屏,最上面是滚轮计数器,怎样才能让滚轮计数2024-08-17
-
插IC卡的燃气表,最下面是水平插IC卡的,上面是液晶显示屏,最上面是滚轮计数器,怎样才能让滚轮计数2024-08-17
-
KT-2 颗粒计数器2024-08-17