diff --git a/useragents.go b/useragents.go index 254c626..dbe0592 100644 --- a/useragents.go +++ b/useragents.go @@ -14,7 +14,7 @@ type useragentEntry struct { Percentage float64 `json:"pct"` } -var defaultUseragent string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" +var defaultUseragent string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.3" var useragents []string = getFreshUseragents() // GetAllUseragents returns all available useragents @@ -31,6 +31,11 @@ func GetRandomUseragent() string { return useragents[r.Intn(len(useragents))] } +// RenewUseragents scrapes a fresh list of useragents +func RenewUseragents() { + useragents = getFreshUseragents() +} + func getFreshUseragents() []string { var freshUserAgents []string = []string{} diff --git a/useragents_test.go b/useragents_test.go index 4e7b067..75a5d00 100644 --- a/useragents_test.go +++ b/useragents_test.go @@ -116,7 +116,7 @@ func TestShouldBeValidUseragent(t *testing.T) { } func TestGetFreshUserAgents(t *testing.T) { - expectedMinimumAmountEntries := 75 + expectedMinimumAmountEntries := 10 if len(useragents) < expectedMinimumAmountEntries { t.Errorf("\ngot: %d\nwanted at least: %d\nfor: len(userAgents)", len(useragents), expectedMinimumAmountEntries) }