38

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. (Edit: it's since been updated.) 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!

Flimm
  • 136,138
  • 45
  • 251
  • 267
Gary Richardson
  • 16,081
  • 10
  • 53
  • 48
  • Are you looking for mobile phones? If so, there is deviceatlas.com ... if not, disregard :) – Noon Silk Sep 21 '09 at 23:19
  • I've integrated a lot of Online Databases in this abstraction layer, maybe you can use it compare them https://github.com/ThaDafinser/UserAgentParser#providers – ThaDafinser Mar 08 '16 at 08:51
  • Mozilla has a good list of User-Agent detection libraries here: https://wiki.mozilla.org/Compatibility/UADetectionLibraries – Collin Krawll Mar 10 '23 at 16:57

10 Answers10

22

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(Linux%20i686%20;%20U;%20en-us)%20Presto/2.2.0

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

http://www.useragentstring.com/?uas=Opera/9.70%20(Linux%20i686%20;%20U;%20en-us)%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...

jtlz2
  • 7,700
  • 9
  • 64
  • 114
ire_and_curses
  • 68,372
  • 23
  • 116
  • 141
4

Browser Capabilities Project

The browscap.ini file is a database which provides a lot of details about browsers and their capabilities, such as name, versions, Javascript support and so on.

The browscap.ini, which provides a lot of details about browsers and their capabilities, such as name, versions, Javascript support and so on.

PHP's native get_browser() function parses this file and provides you with a complete set of information about every browser's details, But it requires the path to the browscap.ini file to be specified in the php.ini browscap directive which is flagged as PHP_INI_SYSTEM.

http://browscap.org/

Community
  • 1
  • 1
GoLang Master
  • 259
  • 5
  • 5
  • 1
    I've found that only the "lite" version of browscap is worth using, the other two larger files add too much overhead. My solution is to start with browscap lite .ini, which is successful about 95% of the time, and if that doesn't work (get_browser() returns "defaultProperties"), then use an online api service like [whatismybrowser](https://github.com/whatismybrowser/api-sample-php-5) – birchy Aug 15 '16 at 22:11
  • It is the best solution I've seen so far. – Eray Erdin Oct 12 '16 at 18:44
3

I was looking for a searchable list of UA's. user-agents.org is searchable, but didn't have nearly enough data. I found http://www.botsvsbrowsers.com/. It is cluttered with ads, but there's a search bar on the right side that was exactly was I was looking for.

undefined
  • 6,208
  • 3
  • 49
  • 59
3

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

Asaph
  • 159,146
  • 25
  • 197
  • 199
  • 1
    -1 This doesn't break down versions/OS's and there are no matches for any of the records in my database. – Gary Richardson Sep 21 '09 at 23:44
  • Have you tried Google Analytics? It won't do bots & spiders that don't process javascript but you'll get almost all your human users tracked. – Asaph Sep 21 '09 at 23:48
2

This thread is a few years old but here is a new resource in search for user agents: ua.theafh.net with 5.4 million agents. You could for example filter for browsers and use wildcard search: http://ua.theafh.net/list.php?s=%22%2A%22&include=yes&class=abr&do=desc - there is also the possibility to download search results as CSV

theafh
  • 478
  • 2
  • 7
2

I found this JSON-encoded list of spiders/bots https://github.com/monperrus/crawler-user-agents appears to be regularly updated as of 2017.

DustWolf
  • 516
  • 7
  • 10
  • It's Syntactic and not real data. – Melroy van den Berg Jan 07 '23 at 03:21
  • @MelroyvandenBerg not sure what you think is missing, but keep in mind that it was a simple list when I posted my answer in 2017. – DustWolf Jan 19 '23 at 14:43
  • So looking at https://github.com/monperrus/crawler-user-agents/blob/master/crawler-user-agents.json, shows me a list of web scrapers user-agent strings from Google, Yahoo etc. Which is fine I guess, but these are not the user-agent strings from real web browsers for example, if you want to mimic a "real" user. – Melroy van den Berg Mar 26 '23 at 16:17
1

Most updated resource in 2017:

https://techblog.willshouse.com/2012/01/03/most-common-user-agents/

They also provide their list in TXT format.

barbolo
  • 3,807
  • 1
  • 31
  • 31
1

We have a huge database of user agents, organised by Software, Operating System, Platform, Hardware Type, Software Type and Rendering Engine:

https://developers.whatismybrowser.com/useragents/explore/

All the other user agent listings do a pretty average job of making it easy to browse related user agents, so when I built this listing, making this easy for users was one of the major priorities behind the design of it.

You can also sign up for the free API which will give you access to our User Agent Parser.

https://developers.whatismybrowser.com/api/

whatismybrowser.com
  • 3,166
  • 2
  • 10
  • 7
  • @whatismybrowser-com is there a way I can supply the user agent in the URL so that I could create a link to your site with an already populated User Agent string to parse? I understand there is an API, but I just want to link to your site with a specific string – lightswitch05 Sep 27 '18 at 14:28
0

You can use http://botopedia.org. It also offers IP validation that helps prevent spoofing.

apaderno
  • 28,547
  • 16
  • 75
  • 90
Igal Zeifman
  • 1,146
  • 7
  • 8
0

Since you posted your question, HTTP::BrowserDetect has since been updated. Once installed, here's how you could use it to parse a text file of user-agent strings:

cat user_agent_strings.txt | perl -nE 'use HTTP::BrowserDetect; $ua =  HTTP::BrowserDetect->new($_); say $ua->browser_string || "unknown";'
Flimm
  • 136,138
  • 45
  • 251
  • 267