PHP implementation to determine whether access is a search engine robot method, the route search engine
The example in this paper describes how PHP realizes whether the access route is a search engine robot. Share to everyone for your reference. The specific analysis is as follows:
Many times we need to identify the site visitors, for real users and search engines for different actions to achieve, then the first need to determine whether it is a search engine.
PHP Judgment method is very simple, by filtering $_server[' http_user_agent ' parameters can be identified, the following is an excerpt from an open source program related source code:
Private Function Getrobot () {if (Empty ($_server[' http_user_agent ')) { return false;} $searchEngineBot = Array ( ' googlebot ' = ' Google ', ' mediapartners-google ' and ' Google ', ' baiduspider ' and ' Baidu ', ' MSNBot ' + ' MSN ', ' yodaobot ' = ' Yodao ', ' Youdaobot ' and ' Yodao ', ' Yahoo! slurp ' and ' Yahoo ', ' Yahoo! slurp china ' = ' yahoo ', ' iaskspider ' = ' iask ', ' Sogou web spider ' = ' sogou ', ' Sogou push spider ' = ' sogou ', ' sosospider ' = ' Soso ', ' spider ' = ' other ', ' crawler ' and ' = ' Other ',); $spider = Strtolower ($_server[' http_user_agent '); foreach ($searchEngineBot as $key = + $value) { if (Strpos ($spider, $key)!== false) { return $value; c18/>}} return false;} Public Function Isrobot () {if ($this->getrobot ()!==false) { return true;} return false;}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/984623.html www.bkjia.com true http://www.bkjia.com/PHPjc/984623.html techarticle PHP to determine whether access to the route is a search engine robot method, the origin of the search engine in this paper, the implementation of PHP to determine whether access is a search engine robot method. Share ...