useragent

package module
v0.0.0-...-b6480ee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

README

UserAgent

In computing, a user agent is software (a software agent) that is acting on behalf of a user, such as a web browser that "retrieves, renders and facilitates end user interaction with Web content" (Wikipedia).
So basically, UserAgent identifies the browser and operating system to the web server.

Example: UserAgent of Google Chrome Version 76.0.3809.100 (Official Build) (64-bit)

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

Installation

go get github.com/x899/useragent

Usage

Source Code

package main

import (
	"fmt"
	"math/rand"
	"strings"
	"time"

	"github.com/x899/useragent"
)

func main() {
	browserCategories := useragent.GetBrowserCategory()
	fmt.Printf("\nBrowser Category: ")
	fmt.Println(strings.Join(browserCategories, " | "))

	category := browserCategories[5]
	browsers := useragent.GetBrowser(category)
	fmt.Printf("\nList of browser in E-mail Client: ")
	fmt.Println(strings.Join(browsers, " | "))

	browser := browsers[0]
	userAgentList := useragent.GetUserAgent(browser)

	rand.Seed(time.Now().Unix())
	fmt.Printf("\nUserAgent for %s: %s\n", browser, userAgentList[rand.Intn(len(userAgentList))])

	data := useragent.Chrome(5)
	fmt.Printf("\nList of 5 Chrome UserAgent: \n")
	for _, d := range data {
		fmt.Println(d)
	}
}

Program Output

$ go run main.go

Browser Category: Crawler | Browser | Mobile Browser | Console | Offline Browser | E-mail Client | Link Checker | E-mail Collector | Validator | Feed Reader | Librarie | Cloud Platform | Other

List of browser in E-mail Client: Thunderbird

UserAgent for Thunderbird: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17

List of 5 Chrome UserAgent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/44.0.2403.155 Safari/537.36
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36

TODO

  • User Agent Analysis
  • Command line tool

Contribution

Feel Free to contribute.
Please follow standard GoLang Coding Guidelines.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AOL

func AOL(limit int) []string

AOL returns list of AOL user agents

func Android

func Android(limit int) []string

Android returns list of Android user agents

func BlackBerry

func BlackBerry(limit int) []string

BlackBerry returns list of BlackBerry user agents

func CURL

func CURL(limit int) []string

CURL returns list of curl user agents

func Chrome

func Chrome(limit int) []string

Chrome returns Google list of Chrome user agents

func Firefox

func Firefox(limit int) []string

Firefox returns list of Firefox user agents

func GetBrowser

func GetBrowser(category string) []string

GetBrowser returns list of valid browsers for a specified category

func GetBrowserCategory

func GetBrowserCategory() []string

GetBrowserCategory returns list of browser categories to choose from.

func GetUserAgent

func GetUserAgent(browser string) []string

GetUserAgent returns list of user agent for specified browser

func Iceweasel

func Iceweasel(limit int) []string

Iceweasel returns list of Iceweasel user agents

func InternetExplorer

func InternetExplorer(limit int) []string

InternetExplorer returns Internet list of Explorer user agents

func Opera

func Opera(limit int) []string

Opera returns list of Opera user agents

func OperaMini

func OperaMini(limit int) []string

OperaMini returns Opera list of Mini user agents

func OperaMobile

func OperaMobile(limit int) []string

OperaMobile returns Opera list of Mobile user agents

func Playstation3

func Playstation3(limit int) []string

Playstation3 returns list of Playstation3 user agents

func PycURL

func PycURL(limit int) []string

PycURL returns list of python's pycurl user agents

func PythonUrllib

func PythonUrllib(limit int) []string

PythonUrllib returns list of python's urllib user agents

func Safari

func Safari(limit int) []string

Safari returns list of Safari user agents

func Thunderbird

func Thunderbird(limit int) []string

Thunderbird returns list of Thunderbird user agents

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL