Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandomUseragent ¶
GetRandomUseragent returns a weighted random user agent from a map of user agents with associated weights.
If the input map is nil, falls back default user agents with predefined weights. A source for current user-agents is https://www.useragents.me/
Parameters:
- useragents (map[string]float32): A map of user agents with associated weights.
Returns:
- string: The selected user agent based on weighted random selection.
func MillisecondToDuration ¶
MillisecondToDuration converts a time duration in milliseconds to a time.Duration.
The ms argument must be able to be cast as a float64. Negative values will be rounded to 0. The function supports int, float32, and float64 types for the ms argument.
Parameters:
- ms (interface{}): The time duration in milliseconds, which can be an int, float32, or float64.
Returns:
- time.Duration: The equivalent time.Duration value.
func RpsToDuration ¶
RpsToDuration converts a rate per second (rps) to a time.Duration delay.
If the rate per second is less than or equal to 0, the function returns a time.Duration of 0.
Parameters:
- rps (float32): The rate per second for which to calculate the time duration delay.
Returns:
- time.Duration: The calculated time duration delay based on the given rate per second.
func UrlsFromFile ¶
UrlsFromFile reads a file containing URLs (one per line) and returns a slice of parsed URL objects.
The function reads the content of the specified file, expecting one URL per line. It trims whitespace from each line and parses it into a URL. The resulting parsed URLs are returned as a slice.
Parameters:
- filename (string): The name of the file containing URLs.
Returns:
- []*url.URL: A slice of parsed URL objects.
- error: An error, if any, encountered during file reading or URL parsing.
Types ¶
This section is empty.