Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read useragent details

This is my user agent

Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31

I know I am using chrome, so I understand it is from chrome version 26. But what is the rest of the information?

How can I read the string. And what all I can collect from userAgent?

What is the best way to parse the userAgent and read each property in it?

like image 303
HaBo Avatar asked Apr 17 '13 14:04

HaBo


People also ask

What is userAgent format?

The format of the User-Agent string in HTTP is a list of product tokens (keywords) with optional comments. For example, if a user's product were called WikiBrowser, their user agent string might be WikiBrowser/1.0 Gecko/1.0. The "most important" product component is listed first.

What is userAgent data?

The user agent is an HTTP header that web browsers and other web applications use to identify themselves and their capabilities. Your web security software captures and logs user agent data when users browse the Internet.

What is this userAgent?

A user agent is any software that retrieves and presents Web content for end users or is implemented using Web technologies. User agents include Web browsers, media players, and plug-ins that help in retrieving, rendering and interacting with Web content.

What is the purpose of userAgent property?

The userAgent property returns the user-agent header sent by the browser to the server. The userAgent property is read-only. The value returned, contains information about the browser name, version and platform. The web specification suggests that browsers should provide as little header information as possible.


1 Answers

From developer.mozilla.org:

Syntax

User-Agent: <product> / <product-version> <comment>

Common format for web browsers:

User-Agent: Mozilla/<version> (<system-information>) <platform> (<platform-details>) <extensions>

Directives

<product>
  A product identifier

<product-version>
  A version number of the product.

<comment>
  Zero or more comments containing sub product information, for example.

Examples

Firefox UA string:

Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0

Chrome UA string:

The Chrome (or Chromium/blink-based engines) user agent string is similar to the Firefox format. For compatibility, it adds strings like "KHTML, like Gecko" and "Safari".

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Safari UA string:

Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1

Internet Explorer UA string:

Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)
like image 78
J0ANMM Avatar answered Jan 02 '23 05:01

J0ANMM