detect_browser

Description

Given the contents of a web request User-Agent header string, determine which platform/OS and browser/version was used to make the request according to that header. The input value should not include the User-Agent: header name, only the value.

The optional second argument can be used to specify which browser detection algorithm to use. Currently, only one algorithm is supported. If no specific algorithm is requested, the default will be used. You can also directly request the default with the value "default". The default algorithm may change over time, so to get an invariant result, specify a specific algorithm.

The supported algorithms are:

algorithm

meaning

default

Use whatever is the latest and greatest

httpagentparser-1.9.3

The Python module httpagentparser, version 1.9.3

lite-2209

A simple detector of major bots and browsers

The return value will be an object with the following fields:

field

meaning

platform

An object describing the source platform. Always returned on non-null input.

platform.name

The name of the platform – for example “Windows”.

platform.version

The version of the platform – for example “10”.

bot

Boolean true, if the agent identifies itself as a web scraper/bot. May be absent.

browser

An object with information about the web browser making the request. May be absent.

browser.name

The name of the browser – for example “Chrome”.

browser.version

The version of the browser – for example “107.0.0.0”

os

An object describing the operating system that made the request. May be absent.

os.name

The name of the OS, if determined.

flavor

An object with additional information about the requester. May be absent.

flavor.name

The name of the remote flavor – for example “MacOS”.

flavor.version

The version of the remote flavor – for example “X 10.15.7”.

If the input is null, the output will be null. Otherwise, at least the platform object will be returned, although the name and/or version may be null individually, depending on how much information could be extracted from the header value. The other objects are returned only if the remote user-agent matches the specifics, with most variation in os and flavor whereas browser and platform are more consistent.

Note that scripts and attacks can easily forge the User-Agent header, so this information is largely helpful when analyzing legitimate traffic, or in conjunction with other fingerprints extracted from the request.

Return type

object

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

detect_browser( useragent [ , algorithm ] )

Argument

Type

Required

Multiple

useragent

string

Required

Only one

algorithm

string

Optional

Only one

Examples

make_col browser:detect_browser(headers['user-agent'])

Assuming there is an object input column headers with the headers from a web request, look up the header user-agent and make the column browser with information about the requester.

user-agent

browser

null

null

some random text

{ platform: { name: null, version: null } }

Mozilla/5.0 (Windows 11.0) Chrome/105.0.0.0

`{ platform: { name: “Windows”, “version”: “11.0” }, os: { name: “Windows”, version: “11.0” }, bot: false, browser: { name: “Chrome”, version: “105.0.0.0” } }