\r\n

51Degrees Device Detection Python  4.4

Device Detection services for 51Degrees Pipeline

cloud/useragentclienthints.py

This example demonstrates detection using user-agent client hints. Each client hints header can only be used to determine the properties for a single component. For example, the sec-ch-ua value can be used to determine the browser of the connecting device, but not other components such as the hardware. We show this by first performing detection with sec-ch-ua only. We then repeat with the user-agent header set as well. Note that the client hint takes priority over the user-agent for detecting browser details.

To run this example, you will need to create a resource key. The resource key is used as shorthand to store the particular set of properties you are interested in as well as any associated license keys that entitle you to increased request limits and/or paid-for properties.

You can create a resource key using the 51Degrees Configurator.

Expected output:

1 ---------------------------------------
2 This example demonstrates detection using user-agent client hints.
3 The sec-ch-ua value can be used to determine the browser of the connecting device, but not other components such as the hardware.
4 We show this by first performing detection with sec-ch-ua only.
5 We then repeat with the user-agent header set as well. Note that the client hint takes priority over the user-agent.
6 Finally, we use both sec-ch-ua and user-agent.Note that sec-ch-ua takes priority over the user-agent for detection of the browser.
7 ---------------------------------------
8 Sec-CH-UA = '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"'
9 User-Agent = 'NOT_SET'
10  Browser = Chrome 89
11  IsMobile = No matching profiles could be found for the supplied evidence.A 'best guess' can be returned by configuring more lenient matching rules.See https://51degrees.com/documentation/_device_detection__features__false_positive_control.html
12 
13 Sec-CH-UA = 'NOT_SET'
14 User-Agent = 'Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/10.1 Chrome/71.0.3578.99 Mobile Safari/537.36'
15  Browser = Samsung Browser 10.1
16  IsMobile = True
17 
18 Sec-CH-UA = '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"'
19 User-Agent = 'Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/10.1 Chrome/71.0.3578.99 Mobile Safari/537.36'
20  Browser = Chrome 89
21  IsMobile = True