熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

PHP通過訪客來路獲取搜索關鍵詞的方法

2022-06-13   來源: PHP編程 

  <?php class keyword{ public function getKeyword($referer){ if(strpos($referer"{ $keyword = $this>getbaidukeyword($referer); }else if(strpos($referer"{ $keyword = $this>getgooglekeyword($referer); }else if(strpos($referer"{ $keyword = $this>getsosokeyword($referer); }else if(strpos($referer"{ $keyword = $this>getsogoukeyword($referer); } return $keyword; } //由來路取得百度關鍵詞 private function getbaidukeyword($str){ $s = strpos($strwd=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } return $str; } //獲得谷歌關鍵詞 private function getgooglekeyword($str){ $s = strpos($str&q=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } return $str; } //獲得SOSO關鍵詞 private function getsosokeyword($str){ $s = strpos($str?w=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); }else{ $s = strpos($str&w=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } } return $str; } //獲得sogou關鍵詞 private function getsogoukeyword($str){ $s = strpos($strquery=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } return $str; } } ?>


From:http://tw.wingwit.com/Article/program/PHP/201311/21223.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.