| 
 | 
 
 
发表于 2011-3-30 12:32:01
|
显示全部楼层
 
 
 
- <?php
 
 - function get_bot(){
 
 -     $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); //关键是这个
 
  
-     if (strpos($useragent, 'googlebot') !== false){
 
 -         return 'Googlebot';
 
 -     }
 
 -     if (strpos($useragent, 'msnbot') !== false){
 
 -         return 'MSNbot';
 
 -     }
 
  
-     if (strpos($useragent, 'slurp') !== false){
 
 -         return 'Yahoobot';
 
 -     }
 
  
-     if (strpos($useragent, 'baiduspider') !== false){
 
 -         return 'Baiduspider';
 
 -     }
 
  
-     if (strpos($useragent, 'sohu-search') !== false){
 
 -         return 'Sohubot';
 
 -     }
 
  
-     if (strpos($useragent, 'lycos') !== false){
 
 -         return 'Lycos';
 
 -     }
 
  
-     if (strpos($useragent, 'robozilla') !== false){
 
 -         return 'Robozilla';
 
 -     }
 
 -     return false;
 
 - }
 
 - ?>
 
  复制代码 |   
 
 
 
 |