spoting spiders/crawlers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scriptmaster
Forum Newbie
Posts: 20
Joined: Wed May 21, 2003 8:26 pm

spoting spiders/crawlers

Post by scriptmaster »

hi

is there any way I can detect a webcrawler/spider hit like "googlebot" on my index.php page?
is there a certain property or sign that only a spider has that PHP can detect to conclude and be sure a certain page request is a spider?

thanks
sorry if my english sucks
User avatar
SystemWisdom
Forum Commoner
Posts: 69
Joined: Sat Mar 26, 2005 5:54 pm
Location: A Canadian South of the 49th Parallel

Post by SystemWisdom »

Well, all spiders/bots have a user-agent signature (as far as I know), and I think googles contains something like: Mediapartners-Google, so maybe something like this will work for you?

Code: Select all

if( stripos( $_SERVER['HTTP_USER_AGENT'], 'Mediapartners-Google' ) !== false )
	{
		// Do stuff..
	}
Post Reply