views:

753

answers:

3

How do you parse your user agent strings? I'm looking to get:

  • Browser
  • Browser Version
  • OS
  • OS Version

from a user agent string. My app is written in perl and was previously using HTTP::BrowserDetect. It's a bit dated and is no longer maintained. I'm in no way tied to using perl for the actual lookup.

I've come to the conclusion that automagic parsing is a lost cause. I was thinking of writing a crud type app to show me a list of unclassified UA's and manually keep them up to date.

Does such an resource already exist that I can tap into? It would be awesome if I could make an HTTP call to look up the user agent info.

Thanks!

+2  A: 

Yes. http://www.user-agents.org/

Asaph
-1 This doesn't break down versions/OS's and there are no matches for any of the records in my database.
Gary Richardson
Asaph
+1  A: 

useragentstring.com has browser and OS information for its user agent strings. There's also an 'analyze' box to submit your own string. I don't know how easy it is to hook up to automatically, but it seems to have the sort of info you want.

Update from Original Posting (don't want to steal your upvotes):

I got this back from the author of http://useragentstring.com/:

I have a simple API, but I'm about to recode a lot of my site, so it might change in the near future. If you link to my site, you can send a useragentstring in a form field or in the querystring with the name 'uas':

http://www.useragentstring.com/?uas=Opera/9.70%20%28Linux%20i686%20;%20U;%20en-us%29%20Presto/2.2.0

this will automaticly parse the string. if you add &getText=all

http://www.useragentstring.com/?uas=Opera/9.70%20%28Linux%20i686%20;%20U;%20en-us%29%20Presto/2.2.0&getText=all

you will get a text file with key value pairs like agent_type=Browser;agent_name=Opera;agent_version=9.70...

ire_and_curses
I've sent an email to the author to see if I can query his service, or download a static database. It seems like the best one so far.
Gary Richardson
A: 

www.handsetdetection.com - Does just that.

Richard Uren
Definitely interesting. Does it do regular browsers too?
Gary Richardson