Documentation
¶
Index ¶
- Variables
- func GetRandomFingerprint() (*types.FingerprintResult, error)
- func GetRandomFingerprintByBrowser(browserType string) (*types.FingerprintResult, error)
- func GetRandomFingerprintByBrowserWithOS(browserType string, os types.OperatingSystem) (*types.FingerprintResult, error)
- func GetRandomFingerprintWithOS(os types.OperatingSystem) (*types.FingerprintResult, error)
- func IsBrowserTypeNotSupported(err error) bool
- func IsNoRandomProfileFound(err error) bool
- func IsRandomProfileInvalid(err error) bool
- type ErrBrowserNotFound
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBrowserTypeNotSupported indicates unsupported browser type ErrBrowserTypeNotSupported = fmt.Errorf("%w: random generator", errs.ErrUnsupportedBrowser) // ErrNoRandomProfileFound indicates no random fingerprint profile found ErrNoRandomProfileFound = fmt.Errorf("%w: random profiles", errs.ErrNoProfilesAvailable) // ErrRandomProfileInvalid indicates invalid random fingerprint profile ErrRandomProfileInvalid = fmt.Errorf("%w: random profile is invalid", generator.ErrFailedToGenerateFingerprint) )
Functions ¶
func GetRandomFingerprint ¶
func GetRandomFingerprint() (*types.FingerprintResult, error)
GetRandomFingerprint selects a full fingerprint from all available profiles.
The function picks a profile from profiles.MappedTLSClients and generates the matching User-Agent and HTTP headers. OS is selected randomly.
Returns:
- *types.FingerprintResult: complete profile, User-Agent, and headers
- error: returned when profile set is empty or profile is invalid
Example:
result, err := GetRandomFingerprint()
if err != nil {
log.Fatal(err)
}
println(result.UserAgent)
println(result.ClientProfile.GetClientHelloStr())
Thread safety: yes. Performance: avg ~7.4us and ~1.8KB allocations.
func GetRandomFingerprintByBrowser ¶
func GetRandomFingerprintByBrowser(browserType string) (*types.FingerprintResult, error)
GetRandomFingerprintByBrowser selects a random fingerprint by browser type. browserType: "chrome", "firefox", "safari", "opera", etc.
func GetRandomFingerprintByBrowserWithOS ¶
func GetRandomFingerprintByBrowserWithOS(browserType string, os types.OperatingSystem) (*types.FingerprintResult, error)
GetRandomFingerprintByBrowserWithOS selects by browser type with optional OS.
func GetRandomFingerprintWithOS ¶
func GetRandomFingerprintWithOS(os types.OperatingSystem) (*types.FingerprintResult, error)
GetRandomFingerprintWithOS selects a random fingerprint with optional OS.
Similar to GetRandomFingerprint, but allows a target OS. If os is empty, OS is chosen randomly.
Args:
- os: target OS, e.g. "Windows NT 10.0; Win64; x64"; empty means random
Returns:
- *types.FingerprintResult: full fingerprint result
- error: returned for invalid OS or empty profile set
Example:
// Use explicit Windows OS
result, err := GetRandomFingerprintWithOS("Windows NT 10.0; Win64; x64")
// Choose OS randomly
result, err := GetRandomFingerprintWithOS("")
Thread safety: yes.
func IsBrowserTypeNotSupported ¶
IsBrowserTypeNotSupported checks whether the error indicates unsupported browser type
func IsNoRandomProfileFound ¶
IsNoRandomProfileFound checks whether the error indicates no random fingerprint profile
func IsRandomProfileInvalid ¶
IsRandomProfileInvalid checks whether the error indicates invalid random fingerprint profile
Types ¶
type ErrBrowserNotFound ¶
type ErrBrowserNotFound struct {
Browser string
}
ErrBrowserNotFound indicates unknown browser type.
func (*ErrBrowserNotFound) Error ¶
func (e *ErrBrowserNotFound) Error() string