user_agent

HTTP User Agent parser for the Go programming language.

  • 所有者: mssola/user_agent
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

UserAgent Build Status GoDoc

UserAgent is a Go library that parses HTTP User Agents.

Usage

package main

import (
    "fmt"

    "github.com/mssola/user_agent"
)

func main() {
    // The "New" function will create a new UserAgent object and it will parse
    // the given string. If you need to parse more strings, you can re-use
    // this object and call: ua.Parse("another string")
    ua := user_agent.New("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11")

    fmt.Printf("%v\n", ua.Mobile())   // => false
    fmt.Printf("%v\n", ua.Bot())      // => false
    fmt.Printf("%v\n", ua.Mozilla())  // => "5.0"

    fmt.Printf("%v\n", ua.Platform()) // => "X11"
    fmt.Printf("%v\n", ua.OS())       // => "Linux x86_64"

    name, version := ua.Engine()
    fmt.Printf("%v\n", name)          // => "AppleWebKit"
    fmt.Printf("%v\n", version)       // => "537.11"

    name, version = ua.Browser()
    fmt.Printf("%v\n", name)          // => "Chrome"
    fmt.Printf("%v\n", version)       // => "23.0.1271.97"

    // Let's see an example with a bot.

    ua.Parse("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")

    fmt.Printf("%v\n", ua.Bot())      // => true

    name, version = ua.Browser()
    fmt.Printf("%v\n", name)          // => Googlebot
    fmt.Printf("%v\n", version)       // => 2.1
}

Copyright © 2012-2019 Miquel Sabaté Solà, released under the MIT License.

主要指標

概覽
名稱與所有者mssola/user_agent
主編程語言Go
編程語言Go (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2012-12-19 10:13:27
推送於2023-02-17 15:55:14
最后一次提交2023-02-17 16:55:00
發布數16
最新版本名稱v0.6.0 (發布於 2023-02-17 16:32:36)
第一版名稱v0.1 (發布於 2012-12-28 18:31:56)
用户参与
星數770
關注者數21
派生數138
提交數189
已啟用問題?
問題數50
打開的問題數22
拉請求數40
打開的拉請求數0
關閉的拉請求數8
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?