AFAIK,
$_SERVER[\'REMOTE_HOST\'] should end up with \"google.com\" or \"yahoo.com\".
but is it the most ensuring method?
any other way out?
The best way to do it with well know and behaving robots, like those you mentioned, is by user agent which you can find on $_SERVER['HTTP_USER_AGENT'].