How to detect search engines on my site? like phpBB

Is there a way to find search engines or crawlers on my site. I saw in phpBB at the administrator that we see and allow search engines, and also see the last bot visit (for example, Google Bot).

any script in PHP? Not Google Analytics or a similar application. I need to implement this for my blog, I think there is some way to find out?

+5
source share
5 answers

You can use either IP addresses or the "User-agent" line sent by the bot or web browser.

Googlebot ( ) , $_SERVER ['HTTP_USER_AGENT'], , . :

Googlebot/2.1 (+ http://www.google.com/bot.html)

NutchCVS/0.8-dev (Nutch; http://lucene.apache.org/nutch/bot.html

Baiduspider + (+ http://www.baidu.com/search/spider_jp.html)

Mozilla/5.0 (X11; U; Linux i686; ru-US) AppleWebKit/531.4 (KHTML, , Gecko)

:  

PHP , . - :

$searchengines = array(
    'Googlebot', 
    'Slurp', 
    'search.msn.com', 
    'nutch', 
    'simpy', 
    'bot', 
    'ASPSeek', 
    'crawler', 
    'msnbot', 
    'Libwww-perl', 
    'FAST', 
    'Baidu', 
    );
$is_se = false;
foreach ($searchengines as $searchengine){
   if (!empty($_SERVER['HTTP_USER_AGENT']) and 
            false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), strtolower($searchengine)))
    {
            $is_se = true;
            break;
    }
}
if ($is_se) { print('Its a search engine!'); } 

, (Google Analytics ) 100% . - , - . , 95% + /.

+10
+5
+1

Google Analytics, :

Piwik PHP , GA. -.

0

Google Analytics .

-2

All Articles