package
module
Version:
v1.0.2
Opens a new window with list of versions in this module.
Published: Oct 17, 2023
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
useragent
客户端请求代理信息解析
注:
安装
go get gitee.com/adam-qiang/useragent@latest
Demo
package main
import (
"fmt"
"gitee.com/adam-qiang/useragent"
)
func main() {
userAgent := "Mozilla/5.0 (Linux; Android 12; HarmonyOS; NCO-AL00; HMSCore 6.11.0.302) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 HuaweiBrowser/14.0.0.322 Mobile Safari/537.36"
ua := useragent.New(userAgent)
fmt.Println("Is Mobile Device:" + fmt.Sprint("", ua.IsMobile))
fmt.Println("Device Name:" + ua.Mobile)
fmt.Println("Platform:" + ua.Os.Platform)
fmt.Println("System Name:" + ua.Os.Name)
fmt.Println("System Version:" + ua.Os.Version)
fmt.Println("Browser Id:" + ua.Browser.Id)
fmt.Println("Browser Id Version:" + ua.Browser.IdVersion)
fmt.Println("Browser:" + ua.Browser.Name)
fmt.Println("Browser Version:" + ua.Browser.Version)
fmt.Println("Engine:" + ua.Browser.Engine)
fmt.Println("Engine Version:" + ua.Browser.EngineVersion)
}
Documentation
¶
Browser
@Description: 浏览器结构体
Part
@Description: User-Agent各部分信息结构体
UserAgent
@Description: User-Agent结构体
New 创建一个新的User-Agent
@param ua string
@return *UserAgent
Source Files
¶
Click to show internal directories.
Click to hide internal directories.