最新消息: 新版网站上线了!!!

php获取百度搜索谷歌引擎的关键字的方法

header("Content-type:text/html;charset=utf-8");
$referer = "http://cn.bing.com/search?q=php%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8Durl&qs=AS&sk=AS1&pq=php%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D&sc=8-7&sp=2&FORM=QBRE&cvid=d297cf2008b04c69866fdb0106126fe0";
//$referer = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'';
if(strpos($referer,"baidu")){
preg_match('/wd\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('wd=','',$ab[0]);
$keyword = urldecode($str);
$form = "baidu";
}elseif(strpos($referer,"google")){
preg_match('/q\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('q=','',$ab[0]);
$keyword = urldecode($str);
$form = "google";
}elseif(strpos($referer,"soso")){
preg_match('/query\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('query=','',$ab[0]);
$keyword = urldecode($str);
$form = "soso";
}elseif(strpos($referer,"sogou")){
preg_match('/query\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('query=','',$ab[0]);
$keyword = urldecode($str);
$form = "sogou";
}
elseif(strpos($referer,"so")){
preg_match('/q\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('q=','',$ab[0]);
$keyword = urldecode($str);
$form = "360";
$keyword = iconv('gbk','utf-8',$keyword);
}elseif(strpos($referer,"bing")){
preg_match('/q\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('q=','',$ab[0]);
$keyword = urldecode($str);
$form = "bing";
}elseif(strpos($referer,"yahoo")){
preg_match('/p\=.*\&/i',$referer,$a);
$ab = explode('&',$a[0]);
$str = str_replace('p=','',$ab[0]);
$keyword = urldecode($str);
$form = "yahoo";
}
var_dump($keyword,$form);

转载请注明:谷谷点程序 » php获取百度搜索谷歌引擎的关键字的方法