Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing the HTTP header user-agent




On Jun 22, 2005, at 11:13 PM, Joachim Haagen Bøe wrote:


The following would be implemented as an else-if, so if a 1 is true, neither of the other checks are made. I think I've included all the "major" browsers I could think of. The application doesn't have to be perfect, but good enough. Also if a user is using firefox and set it up to pretend to be IE, I guess its "OK" for me to store it as IE, etc.


Anyone knows a better way to identify different browsers ?

1. check if the user-agent contains the word "googlebot" => "browser" is googlebot
2. check if the user-agent contains the word "links" => browser is Links
3. check if the user-agent contains the word "lynx" => browser is Lynx
4. check if the user-agent contains the word "safari" => browser is Safari
5. check if the user-agent contains the word "opera" => browser is Opera
6. check if the user-agent contains the word "omniweb" => browser is omniweb
7. check if the user-agent contains the word "netscape" or "ns8" => browser is netscape
8. check if the user-agent contains the word "camino" or "chimera" => browser is camino
9. check if the user-agent contains the word "konqueror" => browser is conqueror
10. check if the user-agent contains the word "msie" => browser is most probably IE at this point
11. check if the user-agent contains the word "firefox" => brower is most probably firefox
12. check if the user-agent contains the word "mozilla" => browser is most probably mozilla
13. Browser underermined, "unknown"



Last time I did this for a script that ran stats via brute force method like this I had about a thousand lines like this for different robots / UAs / devices and such... Its a bit of a mess and my suggestion if you were to do it would be - be careful. In the back side of things (like for stats) its not an issue, but if doing it to try and sniff out a UA to deliver content to thats just a bad idea as the other folks have mentioned.


That said... I tend to think your list above goes at things kinda sideways. It does not catch that netscape 4 and netscape 8 are two totally different products, but netscape 8, firefox and netscape 8 may not be. Same goes for IE on windows or mac. So you should twist the categories a little... check for "gecko" much higher up then break those out if need be (into camino/firefox/netscape/etc). Same goes for the khtml/webkit browsers.

oh, and looking for mozilla, well, thats not going to get you too far as a pile of UAs start their identifier out with Mozilla/X.X


-- [ Chris Casciano ] [ email@hidden ] [ http://placenamehere.com ]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden
References: 
 >Parsing the HTTP header user-agent (From: Joachim Haagen Bøe <email@hidden>)
 >Re: Parsing the HTTP header user-agent (From: Timothy Luoma <email@hidden>)
 >Re: Parsing the HTTP header user-agent (From: Joachim Haagen Bøe <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.