Forum Moderators: open
For perl, would this work?
$database = "/home/sites/site21/web/cgi-local/google.txt";
if ($ENV{'HTTP_USER_AGENT'} =~ /googlebot/) {
open (DATABASE,">>$database");
print DATABASE "REMOTE_ADDR - HTTP_USER_AGENT\n";
close(DATABASE);
}
This is the exact same code that I used for a contest to get visitors E-mail addresses. I put this code in the perl script that I use for the top of my page money maker text links area.
Update: Uggg, in the gogole.txt file it shows up as
REMOTE_ADDR - HTTP_USER_AGENT
REMOTE_ADDR - HTTP_USER_AGENT
Now I'll try...
print DATABASE " $ENV{'REMOTE_ADDR'} - $ENV{'HTTP_USER_AGENT'}\n";
Is there some way to use SSI and a perl script to make a log that only includes the Googlebot?
If so, you can easily make a separate Googlebot log without any scripting. Here's a section of my Apache configuration file with the important bits in bold...
<VirtualHost 192.168.0.100>
ServerName example.com
ServerAlias example.com *.example.com
DocumentRoot /sites/example.com/htdocs
ErrorLog /sites/example.com/logs/error_log
[b]SetEnvIfNoCase User-Agent Googlebot isrobot=true[/b]
SetEnvIf Remote_Addr "192\.168\.0" dontlog
[b]SetEnvIf isrobot true dontlog
CustomLog /sites/example.com/logs/access_log combined env=!dontlog
CustomLog /sites/example.com/logs/robot_log combined env=isrobot[/b]
</VirtualHost>
For those of you running under a Apache/PHP/mySQL environment, GoogleStats would do the job. It's an open source product available in english and french.
Dan
PS: I'm not sure it would be against the TOS to post the URL but, once again, Google is your friend with that single word search term. You may even use the "I'm feeling lucky" button for once ;)