Detect Bot's, Crawlers and Spiders with PHP ( Spanish )


/ Published in: PHP
Save to your folder(s)

This Snnipet detect the querys generated by a bot, crawler or spider.
Este Snnipet detecta las peticiones generadas por los bots, Spiders y Crawlers.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. $robot[] = "googlebot";
  4. $robot[] = "google";
  5. $robot[] = "mediapartners";
  6. $robot[] = "msnbot";
  7. $robot[] = "msn";
  8. $robot[] = "overture";
  9. $robot[] = "lycos";
  10. $robot[] = "seek";
  11. $robot[] = "inktomi";
  12. $robot[] = "yahoo";
  13. $robot[] = "slurp";
  14. $robot[] = "altavista";
  15. $robot[] = "alexa";
  16. $robot[] = "crawler";
  17. $isRobot=false;
  18.  
  19. foreach($robot as $bot){
  20. $str = strtolower($_SERVER['HTTP_USER_AGENT']);
  21. if (strpos($str, $bot) !== false ){
  22. $isRobot=true;
  23. break;
  24. }
  25. }
  26.  
  27.  
  28. //visitas
  29. if($isRobot){
  30.  
  31. //// Esta parte es Opcional
  32. $heads = "MIME-Version: 1.0 rn";
  33. $heads .= "Content-type: text/html; charset=utf-8 rn";
  34.  
  35. $body ="<b>Robot Name:</b> ".$str."<br>";
  36. $body .="<b>Robot Address:</b> ".$_SERVER['REMOTE_ADDR'];
  37.  
  38. mail(mimail, "Detected Bot", $body, $heads);
  39. //// Fin de la Parte Opcional
  40.  
  41. }else{
  42. $vql= "UPDATE bg_articulos SET visitas=visitas+1 WHERE art_id='".$artid."'";
  43. mysql_query($vql);
  44. }
  45.  
  46. ?>

URL: http://www.codigolandia.com/art-Detector+de+Bots,+Spider+y+Crawlers-php-114.tc

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.