uarand

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Unlicense Imports: 3 Imported by: 249

README

uarand

Build Status

Random user-agent producer for go.

Example

package main

import (
	"fmt"

	"github.com/corpix/uarand"
)

func main() {
	fmt.Println(uarand.GetRandom())
}

Save it to snippet.go and run:

go run snippet.go

Which should produce something similar to:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36

License

Unlicense

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default is the UARand with default settings.
	Default = New(
		rand.New(
			rand.NewSource(time.Now().UnixNano()),
		),
	)
)
View Source
var (
	// UserAgents is a list of browser and bots user agents.
	UserAgents = []string{}/* 1280 elements not displayed */

)

Functions

func GetRandom

func GetRandom() string

GetRandom returns a random user agent from UserAgents slice. This version is driven by Default configuration.

Types

type Randomizer

type Randomizer interface {
	Seed(n int64)
	Intn(n int) int
}

Randomizer represents some entity which could provide us an entropy.

type UARand

type UARand struct {
	Randomizer
	UserAgents []string
	// contains filtered or unexported fields
}

UARand describes the user agent randomizer settings.

func New

func New(r Randomizer) *UARand

New return UserAgent randomizer settings with default user-agents list

func NewWithCustomList

func NewWithCustomList(userAgents []string) *UARand

NewWithCustomList return UserAgent randomizer settings with custom user-agents list

func (*UARand) GetRandom

func (u *UARand) GetRandom() string

GetRandom returns a random user agent from UserAgents slice.

Jump to

Keyboard shortcuts

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