Rumah > php教程 > PHP源码 > teks badan

php获取网站关键词

PHP中文网
Lepaskan: 2016-05-25 17:09:48
asal
1041 orang telah melayarinya

1. [代码]php代码              

<?php 
$_SERVER[&#39;HTTP_REFERER&#39;]=&#39;http://www.baidu.com/s?wd=http://www.php.cn/&#39;; 
echo save_www_iiwnet_com_keyword(&#39;http://www.baidu.com/s?wd=http://www.php.cn/&#39;,&#39;http://www.baidu.com/s?wd=http://www.php.cn/&#39;); 
function save_www_iiwnet_com_keyword($domain,$path){ 
 if(strpos($domain, &#39;google.com.tw&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;GOOGLE TAIWAN&#39;; 
  $keywords = urldecode($regs[1]); // google taiwan 
    } 
 if(strpos($domain,&#39;google.cn&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;GOOGLE CHINA&#39;; 
  $keywords = urldecode($regs[1]); // google china 
 } 
 if(strpos($domain,&#39;google.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;GOOGLE&#39;; 
  $keywords = urldecode($regs[1]); // google 
 }elseif(strpos($domain,&#39;baidu.&#39;)!==false && preg_match(&#39;/wd=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;BAIDU&#39;; 
        $keywords = urldecode($regs[1]); // baidu 
    }elseif(strpos($domain,&#39;baidu.&#39;)!==false && preg_match(&#39;/word=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;BAIDU&#39;; 
        $keywords = urldecode($regs[1]); // baidu 
    }elseif(strpos($domain,&#39;114.vnet.cn&#39;)!== false && preg_match(&#39;/kw=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;CT114&#39;; 
        $keywords = urldecode($regs[1]); // ct114 
    }elseif(strpos($domain,&#39;iask.com&#39;)!==false && preg_match(&#39;/k=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;IASK&#39;; 
        $keywords = urldecode($regs[1]); // iask 
    }elseif(strpos($domain,&#39;soso.com&#39;)!==false && preg_match(&#39;/w=([^&]*)/i&#39;,$path,$regs)){ 
  $searchengine = &#39;SOSO&#39;; 
        $keywords = urldecode($regs[1]); // soso 
    }elseif(strpos($domain, &#39;sogou.com&#39;)!==false && preg_match(&#39;/query=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;SOGOU&#39;; 
        $keywords = urldecode($regs[1]); // sogou 
    }elseif(strpos($domain,&#39;so.163.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;NETEASE&#39;; 
        $keywords = urldecode($regs[1]); // netease 
    }elseif(strpos($domain,&#39;yodao.com&#39;)!== false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YODAO&#39;; 
        $keywords = urldecode($regs[1]); // yodao 
    }elseif(strpos($domain,&#39;zhongsou.com&#39;)!==false && preg_match(&#39;/word=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;ZHONGSOU&#39;; 
        $keywords = urldecode($regs[1]); // zhongsou 
    }elseif(strpos($domain,&#39;search.tom.com&#39;)!==false && preg_match(&#39;/w=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;TOM&#39;; 
        $keywords = urldecode($regs[1]); // tom 
    }elseif(strpos($domain,&#39;live.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSLIVE&#39;; 
        $keywords = urldecode($regs[1]); // MSLIVE 
    }elseif(strpos($domain, &#39;tw.search.yahoo.com&#39;)!==false && preg_match(&#39;/p=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YAHOO TAIWAN&#39;; 
        $keywords = urldecode($regs[1]); // yahoo taiwan 
    }elseif(strpos($domain,&#39;cn.yahoo.&#39;)!==false && preg_match(&#39;/p=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YAHOO CHINA&#39;; 
        $keywords = urldecode($regs[1]); // yahoo china 
    }elseif(strpos($domain,&#39;yahoo.&#39;)!==false && preg_match(&#39;/p=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;YAHOO&#39;; 
        $keywords = urldecode($regs[1]); // yahoo 
    }elseif(strpos($domain,&#39;msn.com.tw&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSN TAIWAN&#39;; 
        $keywords = urldecode($regs[1]); // msn taiwan 
    }elseif(strpos($domain,&#39;msn.com.cn&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSN CHINA&#39;; 
        $keywords = urldecode($regs[1]); // msn china 
    }elseif(strpos($domain,&#39;msn.com&#39;)!==false && preg_match(&#39;/q=([^&]*)/i&#39;,$path,$regs)){ 
        $searchengine = &#39;MSN&#39;; 
        $keywords = urldecode($regs[1]); // msn 
    } 
 return $keywords; 
}
Salin selepas log masuk

                   

                   

Label berkaitan:
php
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!