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.2.0.tbz
sha256=00ca1fbb107a1628733dcd95277b9630e466d235a354c8f8055d491c3307e026
sha512=d8e3fa10ef6d95ea3d176aa0c5d43c5ab7f54ff5f8d7ae4f543a19221a79e554e65d1078e7663be6214af4a6b165620735639d8dec1fc8e70158455784ec039d

Description

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

Published: 17 Sep 2020

README

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.

Dependencies (9)

  1. yojson >= "1.6.0"
  2. yaml build & >= "0.2.1"
  3. re >= "1.8.0"
  4. stdio >= "v0.11"
  5. ppx_let
  6. ppx_deriving
  7. ocaml >= "4.05.0"
  8. dune >= "1.3"
  9. base >= "v0.11" & < "v0.17"

Dev Dependencies (2)

  1. yaml with-test & >= "2.0.0"
  2. alcotest with-test & >= "0.8.3"

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.