获取icann根镜像数量
import yaml # pip ibstall pyyaml import requests import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) def download(url): proxies = { "http": None, "https": None} yml_res = requests.get(url,verify=False,proxies=proxies) return yml_res.text def parse_yml(yml_file): try: content = yaml.safe_load(yml_file) except Exception as e: content = "error" return content if __name__ == "__main__": url_index = ["a","b","c","d","e","f","g","h","i","j","k","l","m"] # base_url = "https://root-servers.org/archives/2021-12-31/{}-root.yml" # 1219 # base_url = "https://root-servers.org/archives/2022-04-05/{}-root.yml" # base_url = "https://root-servers.org/root/{}/yaml/" # s = 0 for i in url_index: res = download(base_url.format(i.upper())) p = parse_yml(res) if p=="error": print("stop: {}".format(base_url.format(i))) sites = p["Sites"] print(len(sites)) s += len(sites) print(s)