Parsing user agent OS version empty?

For the lower user agent, the os version seems empty, why doesn't it matter? Will there be no value for this?

User Agent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.22+ (KHTML, like Gecko) Chromium/17.0.963.56 Chrome/17.0.963.56 Safari/535.22+ Debian/7.0 (3.4.2-2.1) Epiphany/3.4.2 

Result:

ua_family = Epiphany, os_family = Debian, os_version = , device_family = Other, device = Desktop 

User agent parsing from here .

+4
source share
1 answer

The main library source file is very easy to read - it looks like it knows a ton about Linux distributions (if they are also not some kind of mobile OS):

MOBILE_DEVICE_FAMILIES = (
    ...
)

PC_OS_FAMILIES = (                   <-- no Linux! :(
    'Windows 95',
    'Windows 98',
    'Windows ME',
    'Solaris',
)

MOBILE_OS_FAMILIES = (
    ...
)

MOBILE_BROWSER_FAMILIES = (
    ...
)

TABLET_DEVICE_FAMILIES = (
    ...
)

TOUCH_CAPABLE_OS_FAMILIES = (
    ...
)

TOUCH_CAPABLE_DEVICE_FAMILIES = (
    ...
)

If all you care about is capturing OS information from your UA string, there are several sections of the UA string, separated by the '/' character:

Mozilla                                  <-- Note: no "User Agent = "
5.0 (X11; Linux x86_64) AppleWebKit
535.22+ (KHTML, like Gecko) Chromium
17.0.963.56 Chrome
17.0.963.56 Safari
535.22+ Debian
7.0 (3.4.2-2.1) Epiphany
3.4.2

(X11; Linux x86_64), Debian, 7.0 (3.4.2-2.1) Epiphany 3.4.2, : " Linux Debian 7.0 x86_64 3.4.2-2.1."

Linux!

0

Source: https://habr.com/ru/post/1570256/


All Articles