|
|
|
|
Thread title: Log GoogleBot |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
10-07-2008, 05:58 PM
|
#1
|
Status: Member
Join date: Oct 2007
Location: Scotland
Expertise:
Software:
Posts: 140
|
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
|
Status: Junior Member
Join date: Sep 2008
Location: US
Expertise:
Software:
Posts: 84
|
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
|
Status: Member
Join date: Oct 2007
Location: Scotland
Expertise:
Software:
Posts: 140
|
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
|
Status: I'm new around here
Join date: May 2008
Location:
Expertise:
Software:
Posts: 15
|
That's a handy little script there
Thanks.. could definitely be useful
|
|
10-25-2008, 06:01 PM
|
#5
|
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
Posts: 15
|
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
|
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
Posts: 3,820
|
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
|
Status: Member
Join date: Oct 2007
Location: Scotland
Expertise:
Software:
Posts: 140
|
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
|
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
Posts: 15
|
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
|
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
Posts: 2,694
|
Originally Posted by wesleyh
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
|
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
Posts: 17
|
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
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|