detect_browser

Description

Identify the browser used for a web request from its User-Agent header.

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

The optional second argument specifies which browser detection algorithm to use. If no specific algorithm is requested, the default is used. You can also directly request the default with the value "default". The default algorithm may change over time, you may wish to specify your desired algorithm to ensure consistent results.

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 is 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 is 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

Optional

Repeatable

Restrictions

useragent

string

no

no

none

algorithm

string

yes

no

constant

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” } }