Web Develop Forum: Log Google Bot - Web Develop Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Log Google Bot Rate Topic: -----

#1 User is offline   paulOr Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 23-October 08
  • Location:Edinburgh, Scotland

Posted 23 October 2008 - 08:47 PM

A really great little way to see how well your site interacts with Google, is to find out how often / much googlebot visits your website, I made this little bit of code so that i could just that!

SQL Database
CODE
CREATE TABLE `googlebot` (
  `counter` int(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


Source Code
CODE
<?php
    if( eregi("googlebot", $_SERVER['HTTP_USER_AGENT']) ) {
        mysql_query("UPDATE `googlebot` SET counter = counter + 1");
    }

    $count = mysql_fetch_row(mysql_query("SELECT `counter` FROM googlebot"));

    print $count[0]." GoogleBot visits.";
?>


More @ paulOr.net
0

#2 User is offline   Bob Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 44
  • Joined: 23-October 08
  • Gender:Male

Posted 23 October 2008 - 10:06 PM

I believe you can get even more detailed statistics about how google crawlers interact with your site (crawling errors, index stats, amount of pages crawler per day, bandwidth usage, etc) with google's webmaster tools (http://www.google.com/webmasters/tools/)
0

#3 User is offline   webtuto Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 19-January 09

Posted 20 January 2009 - 06:52 PM

Here is a simple way of checking if the visitor if your page is a search engine or a normal person. It does this by checking if the user agent returned by $_SERVER['HTTP_USER_AGENT'] contains one of the keywords search engine's user agents usually contain.

CODE
<?php

    //check if user is a bot of some sort
function is_bot()
{
    $bots = array('google','yahoo','msn');
    //takes the list above and returns (google)|(yahoo)|(msn)
    $regex = '('.implode($bots, ')|(').')';
    /*uses the generated regex above to see if those keywords are contained in the user agent variable*/    
    return eregi($regex, $_SERVER['HTTP_USER_AGENT']);
}

?>

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users