PHP implementation to determine whether access is a search engine robot method, the route search engine _php Tutorial

Source: Internet
Author: User

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

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.