package distro import ( "strings" "sync" "github.com/gocolly/colly" ) type Mint struct{} func (d Mint) GetName() string { return "mint" } func (d Mint) GetRepos() []string { return []string{DefaultRepo} } func (d Mint) FetchMirrors(repos []string, repoMirrors chan<- RepoMirror, done *sync.WaitGroup) { defer done.Done() c := colly.NewCollector( colly.AllowedDomains("linuxmint.com"), ) c.OnHTML("div.container table.table tr td:nth-child(3)", func(h *colly.HTMLElement) { url := h.Text if strings.HasPrefix(url, "http:") || strings.HasPrefix(url, "https:") || strings.HasPrefix(url, "ftp:") { if !strings.HasSuffix(url, "/") { url += "/" } repoMirrors <- RepoMirror{d.GetName(), DefaultRepo, url} } }) c.Visit("https://linuxmint.com/mirrors.php") c.Wait() }