La variable HTTP_USER_AGENT
Précédent < Langue de votre visiteur
Une autre variable est une source d'information interessante : HTTP_USER_AGENT. Elle donne des informations précises sur le navigateur et le système d'exploitation.
Si vous utilisez la variable sans l'analyser, vous obtiendrez :
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
avec la ligne ASP suivante
<%response.write(Request.ServerVariables("HTTP_USER_AGENT"))%>
La variable dans l'état brut n'est pas très parlante. Il faudra donc l'analyer. La première routine extrait le navigateur.
<% function Donne_navigateur(Info_Systeme) Info_Navigateur = "" If Instr(Info_Systeme, "MSIE") <> 0 Then Info_Navigateur = "Internet Explorer" If Instr(Info_Systeme, "Opera") <> 0 Then Info_Navigateur = "Opera" If Instr(Info_Systeme, "Netscape") <> 0 Then Info_Navigateur = "Netscape 6" If Instr(Info_Systeme, "Mozilla/4.7") <> 0 Then Info_Navigateur = "Netscape 4.7" If Instr(Info_Systeme, "Mozilla/4.5") <> 0 Then Info_Navigateur = "Netscape 4.5" If Instr(Info_Systeme, "amaya") <> 0 Then Info_Navigateur = "Amaya" If Instr(Info_Systeme, "Konqueror") <> 0 Then Info_Navigateur = "Konqueror" If Instr(Info_Systeme, "Gecko") <> 0 Then Info_Navigateur = "K-Meleon" If Info_Navigateur = "" Then Info_Navigateur = Info_Systeme Donne_navigateur = Info_Navigateur end function %>
Pour en extraire le système d'exploitation, il faut construire une routine qui ressemble à ceci :
<% function Donne_Plateforme(Info_Systeme) Info_Plateforme = "" If Instr(Info_Systeme, "Windows NT 5.0") <> 0 Then Info_Plateforme = "Windows 2000" If Instr(Info_Systeme, "Windows 2000") <> 0 Then Info_Plateforme = "Windows 2000" If Instr(Info_Systeme, "Windows NT 5.1") <> 0 Then Info_Plateforme = "Windows XP" If Instr(Info_Systeme, "Windows XP") <> 0 Then Info_Plateforme = "Windows XP" If Instr(Info_Systeme, "Windows 98") <> 0 Then Info_Plateforme = "Windows 98" If Instr(Info_Systeme, "Win98") <> 0 Then Info_Plateforme = "Windows 98" If Instr(Info_Systeme, "Me") <> 0 Then Info_Plateforme = "Windows ME" If Instr(Info_Systeme, "Win 9x") <> 0 Then Info_Plateforme = "Windows 9x" If Instr(Info_Systeme, "Windows 95") <> 0 Then Info_Plateforme = "Windows 95" If Instr(Info_Systeme, "Win95") <> 0 Then Info_Plateforme = "Windows 95" If Instr(Info_Systeme, "Mac") <> 0 Then Info_Plateforme = "Mac OS" If Instr(Info_Systeme, "Apple") <> 0 Then Info_Plateforme = "Mac OS" If Instr(Info_Systeme, "Sun") <> 0 Then Info_Plateforme = "Sun OS" If Instr(Info_Systeme, "Linux") <> 0 Then Info_Plateforme = "Linux" If Instr(Info_Systeme, "X11") <> 0 Then Info_Plateforme = "Linux" If Instr(Info_Systeme, "Unix") <> 0 Then Info_Plateforme = "Unix" If Info_Plateforme = "" Then If Instr(Info_Systeme, "NT") <> 0 Then Info_Plateforme = "Windows NT" End If If Info_Plateforme = "" Then Info_Plateforme = Info_Systeme End If Donne_Plateforme = Info_Plateforme end function %>
Vous remarquerez que dans les deux routines, une place est laissée à l'inconnu. Cela permet de rester ouvert pour de nouveaux navigateurs et de nouveaux navigateurs.
Les robots sont égallement visés. Leur signature ne réponds pas toujours à des régles précises.
Téléchargez le source (Zip)
Suite > Infos visiteurs
|
 |
| Toutes les heures, le serveur contrôle que votre site est en ligne. En cas de problème, un mail vous est envoyé. |
 |
| Vous avez l'habitude d'oublier les dates importantes? Oubli vous prévient gratuitement par email ! |
|
|