Forum Moderators: coopster & phranque

Message Too Old, No Replies

Log more than one user agent?

How do I change this to do that.

         

Jesse_Smith

10:06 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What do you change in this code so it logs more than one search engine? This logs Googlebot, but I want to log all the major search engine robots.

if ($ENV{'HTTP_USER_AGENT'} =~ /googlebot/) {
open (DATABASE,">>$database");
print DATABASE "$ENV{'REMOTE_ADDR'} - $ENV{'HTTP_USER_AGENT'} - $ENV{'SCRIPT_URL'} - $shortdate\n";
close(DATABASE);
}

jatar_k

10:47 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if ($ENV{'HTTP_USER_AGENT'} =~ /googlebot/) {

change that bit to the specific name that shows up in your logs for each engine you would like to track.

Jesse_Smith

11:47 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would this be correct?

if ($ENV{'HTTP_USER_AGENT'} =~ /googlebot/Scooter/Northern Light Gulliver/Infoseek Sidewinder/Inktomi Slurp/Direct Hit Grabber/fido/) {

grahamstewart

12:12 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the slashes indicate a regular expression (you didn't mention what language this is)

In which case you want

/(googlebot¦Scooter¦Northern Light¦Gulliver¦Infoseek¦Sidewinder¦Inktomi Slurp¦Direct Hit Grabber¦fido)/

Jesse_Smith

12:25 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perl, cgi.

grahamstewart

12:37 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Guessed as much, I don't use Perl, but I'm guessing thats the right syntax. Any Perl user care to correct or confirm?

Jesse_Smith

12:44 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or possibly this?

if ($ENV{'HTTP_USER_AGENT'} =~ /googlebot?Scooter?Northern Light Gulliver?Infoseek Sidewinder?Inktomi Slurp?Direct Hit Grabber?fido/) {

because one of my perl chat scripts has this

if($ENV{'REMOTE_ADDR'} =~ /\b(206\.58?204\.203?206\.163?65\.163)/) {

to let users know if the user is the webmaster.

Edit: The? should be the line going up and down, the mark above the return button. It looks like that's what you posted.

eaden

2:39 am on Apr 18, 2003 (gmt 0)

10+ Year Member



no,? is match one character I think.

did grahamstewart's suggestion work?

Jesse_Smith

6:36 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got it working, got a few Altavista robot hits. It's not?, it's the mark in the button just above the return key, the line going up and down.

grahamstewart

8:06 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the mark in the button just above the return key

aka ¦

On my keyboard it appears as shift \