<?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