package user-agent-parser

  1. Overview
  2. Docs
OCaml implementation of the user agent parse rules of uap-core

Install

Dune Dependency

Authors

Maintainers

Sources

user-agent-parser-0.1.3.tbz
sha256=702c4c20d41c9f4d95f92ac3b7894f62b701c087dc99e84639aa64b8a0527b60
sha512=66c7896afcbd137cc47bad407df419c0b177d156339820eaa81907366815df8dd8fcb1ca7e92bb7ead9ee47f7eb6042ead538cf0fd40a7c225570421eb94d7b2

README.md.html

user-agent-parser (ocaml)

Ocaml implementation of the user agent parse rules from https://github.com/ua-parser/uap-core

Documentation: https://issuu.github.io/uap-ocaml/

Example

(* init compiles a bunch of regexes, so try to do this just once *)
let uaparser = User_agent_parser.init () in

let user_agent = "Mozilla/5.0 (Windows; Windows NT 5.1; rv:2.0b3pre) Gecko/20100727 Minefield/4.0.1pre" in
let parsed = User_agent_parser.parse uaparser user_agent in
Printf.printf "%s\n" parsed.ua.family;                     (* Firefox (Minefield) *)
Printf.printf "%s %s\n" parsed.os.family parsed.os.major;  (* Windows XP *)
Printf.printf "%s\n" parsed.device.family;                 (* Other *)

let user_agent = "Mozilla/5.0 (Linux; U; Android 4.2.2; de-de; PEDI_PLUS_W Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" in
let parsed = User_agent_parser.parse uaparser user_agent in
Printf.printf "%s\n" parsed.ua.family;                     (* Android *)
Printf.printf "%s %s\n" parsed.os.family parsed.os.major;  (* Android 4 *)
Printf.printf "%s\n" parsed.device.family                  (* Odys PEDI PLUS W *)

License

Apache 2.0, see LICENSE.

OCaml

Innovation. Community. Security.