Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1144 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Log GoogleBot

Thread title: Log GoogleBot
Closed Thread    
    Thread tools Search this thread Display Modes  
10-07-2008, 05:58 PM
#1
paulOr is offline paulOr
paulOr's Avatar
Status: Member
Join date: Oct 2007
Location: Scotland
Expertise:
Software:
 
Posts: 140
iTrader: 2 / 100%
 

paulOr is on a distinguished road

  Old  Log GoogleBot

Don't know if anything like this has been posted before, but ill post it anyway.
Made a little script to show me how many times GoogleBot has hit my website. Nothing special.

SQL Database
Code:
CREATE TABLE `googlebot` (
  `counter` int(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Source Code
PHP 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.";
?>
Enjoy!

10-09-2008, 11:59 PM
#2
Nathan King is offline Nathan King
Status: Junior Member
Join date: Sep 2008
Location: US
Expertise:
Software:
 
Posts: 84
iTrader: 4 / 100%
 

Nathan King is an unknown quantity at this point

  Old

What might be useful is to have it store the date/time that the bot hit the page. Although this would require you to insert new rows instead of just bumping up the counter, it would be handy to know.

10-10-2008, 10:47 PM
#3
paulOr is offline paulOr
paulOr's Avatar
Status: Member
Join date: Oct 2007
Location: Scotland
Expertise:
Software:
 
Posts: 140
iTrader: 2 / 100%
 

paulOr is on a distinguished road

  Old

Yea i was thinking of addig that, but i didnt need it for my website, so i just didnt.

10-11-2008, 03:32 PM
#4
lifetalk is offline lifetalk
Status: I'm new around here
Join date: May 2008
Location:
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

lifetalk is on a distinguished road

  Old

That's a handy little script there
Thanks.. could definitely be useful

10-25-2008, 06:01 PM
#5
wesleyh is offline wesleyh
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

wesleyh is on a distinguished road

  Old

Meh, that's not very good. It will save every pageview that googlebot does so your DB will be very full. For such a task it would be best to use a statistics package like google analytics.

10-25-2008, 06:29 PM
#6
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

I'm not sure how "very full" the database will get when all that's being updated is a single column, in a single row, in a single database. For some, it might be nice to have more detailed logging and statistics but for the purpose for which Paul's using it, the code above is just fine.

10-25-2008, 06:37 PM
#7
paulOr is offline paulOr
paulOr's Avatar
Status: Member
Join date: Oct 2007
Location: Scotland
Expertise:
Software:
 
Posts: 140
iTrader: 2 / 100%
 

paulOr is on a distinguished road

  Old

Nice to have some positive feed back. cheers salathe.
It was never intended to give a detailed view into what activity googlebot does on your site, just how many times it hits your site. Useful or not.

10-25-2008, 07:14 PM
#8
wesleyh is offline wesleyh
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

wesleyh is on a distinguished road

  Old

Oops, thought it did an insert on each pageview, not an update.. Still, there are better things. Good stuff to learn php though.

10-25-2008, 08:50 PM
#9
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old

Originally Posted by wesleyh View Post
Meh, that's not very good. It will save every pageview that googlebot does so your DB will be very full. For such a task it would be best to use a statistics package like google analytics.
Having thousands of rows in MySQL won't slow you down, fyi. It's said best by Aaron Egaas "data storage is cheap, runtime processing is not."

11-09-2008, 08:08 PM
#10
swg is offline swg
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
 
Posts: 17
iTrader: 0 / 0%
 

swg is on a distinguished road

  Old

Nice script - but wouldn't it be easier to just sign up to Google's webmaster tools? It provides far more detailed information, such as where it has crawled, how many pages, when, etc. plus any problems - and it's all hosted on Google

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed