Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Codice per tracciare gli spiderbots

    Ho una funzione sche scrive su file quando passano i vari bot:

    Codice PHP:
    if (strstr($_SERVER['HTTP_USER_AGENT'], 'Googlebot')){$bot='Googlebot';}
    else if (
    strstr($_SERVER['HTTP_USER_AGENT'], 'Mediapartners')){$bot='Adsense';}
    else if (
    strstr($_SERVER['HTTP_USER_AGENT'], 'Slurp')){$bot='Hot Bot';}
    else if (
    strstr($_SERVER['HTTP_USER_AGENT'], 'ichiro')){$bot='ichiro';}
    else if (
    strstr($_SERVER['HTTP_USER_AGENT'], 'msnbot')){$str_bot='Msn';}
    else if (
    strstr($_SERVER['HTTP_USER_AGENT'], 'bingBot')){$str_bot='Bing';} 
    Il guaio è che funziona a dovere von googlebot o ichiro, ma fallisce se invece il bot è bingbot o msnbot.

    A cosa può essere dovuto questo strano comportamento?
    Grazie
    http://www.xprenotare.it

  2. #2
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,503
    Non me ne sono mai occupato, ma non è che quelli che non ti funzionano abbiano cambiato la stringa identificativa e non riportino più le parole che cerchi?

  3. #3
    Non è cambiato nulla, ho controllato il log del server è la stringa è uguale
    http://www.xprenotare.it

  4. #4
    Trovato e corretto un errore: la variabile dove metto il risultato è scritta in 2 modi diversi: $str_bot e $bot.

    Ma messo a posto qusto, non riesco ancora a intrappoare un bot in piarticolare, che si presenta con questa stringa user_agent:
    findlinks/2.6 (+http://wortschatz.uni-leipzig.de/findlinks/)

    Ho provato in questi 3 modi ma falliscono tutti:
    else if (strstr($_SERVER['HTTP_USER_AGENT'], 'leipzig')){$bot='lp1';}
    else if (strstr($_SERVER['HTTP_USER_AGENT'], 'links')){$bot='lp2l';}
    else if (strstr($_SERVER['HTTP_USER_AGENT'], 'worts')){$bot='lp3';}
    http://www.xprenotare.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.