https://github.com/sneako/os_detect
Quickly determine the operating system from user-agent strings with binary pattern matching.
https://github.com/sneako/os_detect
elixir user-agent user-agent-parser
Last synced: 10 months ago
JSON representation
Quickly determine the operating system from user-agent strings with binary pattern matching.
- Host: GitHub
- URL: https://github.com/sneako/os_detect
- Owner: sneako
- Created: 2020-07-15T20:58:41.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-09-06T08:42:13.000Z (almost 3 years ago)
- Last Synced: 2025-01-31T23:05:14.639Z (over 1 year ago)
- Topics: elixir, user-agent, user-agent-parser
- Language: Elixir
- Homepage: https://hex.pm/packages/os_detect
- Size: 94.7 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OsDetect
A simple, fast user-agent parsing library.
It is much faster than other user agent parsing libraries because it users
binary pattern matching for many common cases, and it *only* returns the
operating system name, browser name, and a type atom.
It can also detect most types of bots/scrapers that are not actively trying to
hide their identities.
See [OsDetect.Result](/lib/os_detect/result.ex) for all possible types.
Most other libraries tend to be purely regex based and return more information,
much more slowly.
## Installation
Add `os_detect` to your `mix.exs` dependencies:
```elixir
def deps do
[
{:os_detect, "~> 0.2.0"}
]
end
```
## Usage
```elixir
OsDetect.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36")
%OsDetect.Result{browser: "chrome", os: "mac os", type: :desktop}
```