代码实现

func UOS(url string) {
	links := make([]string, 0)
	// links = append(links, "|iso|")
	// links = append(links, "|:---:|")
	resp, err := soup.Get(url)
	if err != nil {
		os.Exit(1)
	}
	doc := soup.HTMLParse(resp)
	isos := doc.FindAll("a")
	for _, iso := range isos {
		href := iso.Attrs()["href"]
		link := strings.Join([]string{url, href}, "/")
		if strings.Contains(link, "iso") {
			log.Info.Println(link)
			line := strings.Join([]string{"|[", href, "](", link, ")|"}, "")
			links = append(links, line)
		} else {
			log.Debug.Printf("link %v\n", link)
		}
	}
	util.WriteLines("UOS.md", links)
}

运行代码

func TestUOS(t *testing.T) {
	var urls = []string{"https://cdimage-download.chinauos.com",
		"https://cdimage-download.chinauos.com/education",
		"https://cdimage-download.chinauos.com/home",
		"https://cdimage-download.chinauos.com/home-ditch",
		"https://cdimage-download.chinauos.com/professional-wayland",
		"https://cdimage-download.chinauos.com/sp1-fix"}
	for _, url := range urls {
		UOS(url)
	}
}

成果

iso
uniontechos-20-desktop-professional-1020-amd64.iso
uniontechos-20-desktop-professional-1020-arm64.iso
uniontechos-20-desktop-professional-1020-mips64el.iso
uniontechos-desktop-20-professional-1021_amd64.iso
uniontechos-desktop-20-professional-1021_arm64.iso
uniontechos-desktop-20-professional-1021_mips64el.iso
uniontechos-desktop-20-professional-1022_amd64.iso
uniontechos-desktop-20-professional-1022_arm64.iso
uniontechos-desktop-20-professional-1022_mips64el.iso
uniontechos-desktop-20-professional-1030-fix_amd64.iso
uniontechos-desktop-20-professional-1030-fix_arm64.iso
uniontechos-desktop-20-professional-1030-fix_mips64el.iso
uniontechos-desktop-20-professional-1030_amd64.iso
uniontechos-desktop-20-professional-1030_arm64.iso
uniontechos-desktop-20-professional-1030_mips64el.iso
uniontechos-desktop-20-professional-1031_amd64.iso
uniontechos-desktop-20-professional-1031_arm64.iso
uniontechos-desktop-20-professional-1031_mips64el.iso
uniontechos-desktop-20-professional-1032-sw_64-20210729-1546-B5.iso
uniontechos-desktop-20-professional-1032_amd64.iso
uniontechos-desktop-20-professional-1032_arm64.iso
uniontechos-desktop-20-professional-1032_mips64el.iso
uniontechos-desktop-20-professional-1040-amd64.iso
uniontechos-desktop-20-professional-1040-arm64.iso
uniontechos-desktop-20-professional-1040-fix-amd64.iso
uniontechos-desktop-20-professional-1040-fix-arm64.iso
uniontechos-desktop-20-professional-1040-fix-mips64el.iso
uniontechos-desktop-20-professional-1040-mips64el.iso
uniontechos-desktop-20-professional-1041-amd64.iso
uniontechos-desktop-20-professional-1041-arm64.iso
uniontechos-desktop-20-professional-1041-mips64el.iso
uniontechos-desktop-20-professional-1041-sw_64-20211112-1754.iso
uniontechos-desktop-20-professional-1042-amd64.iso
uniontechos-desktop-20-professional-1042-arm64.iso
uniontechos-desktop-20-professional-1042-mips64el.iso
uniontechos-desktop-20-professional-1043-amd64.iso
uniontechos-desktop-20-professional-1043-arm64.iso
uniontechos-desktop-20-professional-1043-loongarch64.iso
uniontechos-desktop-20-professional-1043-mips64el.iso
uniontechos-desktop-20-professional-1043-sw_64-831-sw_64-20220307-0947.iso
uniontechos-desktop-20-professional-1050-amd64.iso
uniontechos-desktop-20-professional-1050-arm64.iso
uniontechos-desktop-20-professional-1050-loongarch64.iso
uniontechos-desktop-20-professional-1050-mips64el.iso
uniontechos-server-20-1000c-amd64.iso
uniontechos-server-20-1000c-arm64.iso
uniontechos-server-20-1001c-amd64.iso
uniontechos-server-20-1001c-arm64.iso
uniontechos-server-20-1002a-amd64.iso
uniontechos-server-20-1002a-arm64.iso
uniontechos-server-20-1020a-amd64.iso
uniontechos-server-20-1020a-arm64.iso
uniontechos-server-20-1020e-amd64.iso
uniontechos-server-20-1020e-arm64.iso
uniontechos-server-20-1021a-amd64.iso
uniontechos-server-20-1021a-arm64.iso
uniontechos-server-20-1021e-amd64.iso
uniontechos-server-20-1021e-arm64.iso
uniontechos-server-20-1040d-amd64.iso
uniontechos-server-20-1040d-arm64.iso
uniontechos-server-20-1040d-mips64el.iso
uniontechos-server-20-1040d-sw_64-20210813-1619-B1.iso
uniontechos-server-20-1040d-sw_64-20220127-1644-B2.iso
uniontechos-server-20-1050a-amd64.iso
uniontechos-server-20-1050a-arm64.iso
uniontechos-server-20-1050a-loongarch64.iso
uniontechos-server-20-1050d-amd64.iso
uniontechos-server-20-1050d-arm64.iso
uniontechos-server-20-1050e-amd64.iso
uniontechos-server-20-1050e-arm64.iso
uniontechos-server-20-enterprise-1020-amd64.iso
uniontechos-server-20-enterprise-1020-arm64.iso
uniontechos-server-20-enterprise-1020-mips64el.iso
uniontechos-server-20-enterprise-1021-amd64.iso
uniontechos-server-20-enterprise-1021-arm64.iso
uniontechos-server-20-enterprise-1021-mips64el.iso
uniontechos-server-20-enterprise-1030-amd64.iso
uniontechos-server-20-enterprise-1030-arm64.iso
uniontechos-server-20-enterprise-1030-mips64el.iso
uniontechos-server-20-enterprise-1030-sw_64-20210810-1018-B5.iso
uniontechos-server-20-euler-1010-arm64.iso
uos-20-SP1-desktop-amd64.iso
uos-20-SP1-desktop-arm64.iso
uos-20-SP1-desktop-mips64el.iso
uos-20-SP1-server-amd64.iso
uos-20-SP1-server-arm64.iso
uos-20-SP1-server-mips64el.iso
uos-20-alpha-desktop-amd64.iso
uos-20-alpha-desktop-arm64.iso
uos-20-alpha-desktop-mips64el.iso
uos-20-alpha-server-amd64.iso
uos-20-alpha-server-arm64.iso
uos-20-alpha-server-mips64el.iso
uos-20-beta-desktop-amd64.iso
uos-20-beta-desktop-arm64.iso
uos-20-beta-desktop-mips64el.iso
uos-20-beta-server-amd64.iso
uos-20-beta-server-arm64.iso
uos-20-beta-server-mips64el.iso
uos-20-desktop-20200326-2232-B6-sw_64.iso
uos-20-desktop-20200417-1924-B8-sp1-sw_64.iso
uos-20-desktop-amd64-1011.iso
uos-20-desktop-amd64.iso
uos-20-desktop-arm64-1011.iso
uos-20-desktop-arm64.iso
uos-20-desktop-mips64el-1011.iso
uos-20-desktop-mips64el.iso
uos-20-home-desktop-amd64.iso
uos-20-rc-desktop-amd64.iso
uos-20-rc-desktop-arm64.iso
uos-20-rc-desktop-mips64el.iso
uos-20-rc-server-amd64.iso
uos-20-rc-server-arm64.iso
uos-20-rc-server-mips64el.iso
uos-20-server-20200326-2213-B6-sw_64.iso
uos-20-server-20200417-1906-B8-sp1-sw_64.iso
uos-20-server-amd64.iso
uos-20-server-arm64.iso
uos-20-server-mips64el.iso
统信UOS桌面专业版loongarch64架构体验版.iso
uniontechos-desktop-20-e-1042-amd64.iso
uniontechos-desktop-20-e-1042-arm64.iso
uniontechos-desktop-20-e-1042-kernel-4-19-amd64.iso
uniontechos-desktop-20-e-1042-mips64el.iso
uniontechos-desktop-20-e-1043-loongarch64.iso
uniontechos-desktop-21.1-home-amd64.iso
uniontechos-desktop-home-amd64-13000034.iso
uniontechos-desktop-20-professional-1040-kirin990-arm64-20210929-build188.iso
uos-20-desktop-amd64.iso
uos-20-desktop-arm64.iso
uos-20-desktop-mips64el.iso
uos-20-server-amd64.iso
uos-20-server-arm64.iso
uos-20-server-mips64el.iso