8.17.0.3
User Agents
This package provides a user agent parser based on uap-core.
1 Reference
(require net/user-agents) | package: user-agents-lib |
procedure
(parse-user-agent user-agent) →
ua? os? dev? user-agent : string?
Returns the parsed user agent, operating system and device
information for the given user-agent.
struct
(struct ua (family major minor patch) #:extra-constructor-name make-ua) family : string? major : (or/c #f string?) minor : (or/c #f string?) patch : (or/c #f string?)
Represents parsed user agent information.
struct
(struct os (family major minor patch patch-minor) #:extra-constructor-name make-os) family : string? major : (or/c #f string?) minor : (or/c #f string?) patch : (or/c #f string?) patch-minor : (or/c #f string?)
Represents parsed operating system information.
struct
(struct dev (family brand model) #:extra-constructor-name make-dev) family : string? brand : (or/c #f string?) model : (or/c #f string?)
Represents parsed device information.
These procedures return normalized strings representing the given
info struct instances.
Examples:
> (require net/user-agents)
> (define ua-str (string-append "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"))
> (define-values (ua os dev) (parse-user-agent ua-str)) > (~ua ua) "Chrome 135.0.0"
> (~os os) "Mac OS X 10.15.7"
> (~dev dev) "Apple Mac"