91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

python-dnspod:批量添加域名、解析記錄和修改解析記錄等

發布時間:2020-06-01 19:36:34 來源:網絡 閱讀:12995 作者:小生博客 欄目:網絡安全

小生博客:http://xsboke.blog.51cto.com

                    -------謝謝您的參考,如有疑問,歡迎交流

  1. 此腳本全部使用python編寫
  2. 共有四個文件:First_Grade.py Second_Grade.py setup.py README
  3. 使用前先查看文件【README.py】的說明

  1. 第一個python文件【First_Grade.py】,這是最底層的類和函數
import requests

'''
Directory:

Global_Var                          --              通用變量
Dns_Add_Domain_Record               --              添加域名和解析記錄
Dns_Del_Domain                      --              刪除域名
Dns_Add_Record                      --              添加記錄
Dns_Alter_Record                    --              修改記錄
Dns_Del_Record                      --              刪除記錄
Dns_Get_Domain_List                 --              獲取域名列表

'''

class Global_Var:
    '''通用變量'''
    def __init__(self,Login_Token):
        self.Login_Token = Login_Token
        self.Format = 'json'
        self.Response_record_file = 'record_log.txt'

        self.Add_Domain_URL = 'https://dnsapi.cn/Domain.Create'             # 添加域名
        self.Del_Domain_URL = 'https://dnsapi.cn/Domain.Remove'             # 刪除域名
        self.Add_Record_URL = 'https://dnsapi.cn/Record.Create'             # 添加記錄
        #self.Alter_Record_URL = 'https://dnsapi.cn/Record.Modify'         # 修改記錄
        self.Alter_Record_URL = 'https://dnsapi.cn/Batch.Record.Modify'     # 批量修改記錄
        self.Get_Record_URL = 'https://dnsapi.cn/Record.List'               # 獲取記錄列表
        self.Del_Record_URL = 'https://dnsapi.cn/Record.Remove'             # 刪除記錄
        self.Get_Domain_List_URL = 'https://dnsapi.cn/Domain.List'          # 獲取域名列表

class Dns_Add_Domain_Record(Global_Var):
    '''添加域名和解析記錄'''

    def Add_Domain(self,Domains_List):
        '''添加域名'''
        for Domain in Domains_List:
            r = requests.post(self.Add_Domain_URL, data={'login_token': self.Login_Token,
                                                    'format': self.Format,
                                                    'domain': Domain,
                                                    })
            resoponse_record_json = r.json()
            if resoponse_record_json["status"]["code"] == "1":

                print("域名:\033[34m" + resoponse_record_json["domain"]["domain"] +
                      "\033[0m,添加成功;域名ID:\033[34m" + resoponse_record_json["domain"]["id"] + "\033[0m.")

                successful_message = "域名:" + resoponse_record_json["domain"]["domain"] + \
                                     ",添加成功;域名ID:" + resoponse_record_json["domain"]["id"] + "."

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = successful_message + '\n'
                    file.writelines(line)

            else:
                print("域名:\033[31m%s\033[0m,添加失敗,錯誤信息:\033[31m"
                      % (Domain) + resoponse_record_json["status"]["message"] + "\033[0m")

                error_message = "域名:%s,添加失敗,錯誤信息:" \
                                % (Domain) + resoponse_record_json["status"]["message"] + "."

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = error_message + '\n'
                    file.writelines(line)

    def Add_Record(self,Domains_List,Sub_Domian_List,Record_Type,Record_Line_value,Value):
        '''添加域名和解析記錄'''
        for Domain in Domains_List:
            r = requests.post(self.Add_Domain_URL, data={'login_token': self.Login_Token,
                                                    'format': self.Format,
                                                    'domain': Domain,
                                                    })
            resoponse_record_json = r.json()
            if resoponse_record_json["status"]["code"] == "1":
                print("域名:\033[34m" + resoponse_record_json["domain"]["domain"] +
                      "\033[0m,添加成功;域名ID:\033[34m" + resoponse_record_json["domain"]["id"] +
                      "\033[0m.")

                successful_message = "域名:" + resoponse_record_json["domain"]["domain"] + \
                                     ",添加成功;域名ID:" + resoponse_record_json["domain"]["id"] + "."

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = successful_message + '\n'
                    file.writelines(line)

            else:
                print("域名:\033[31m%s\033[0m,添加失敗,錯誤信息:\033[31m"
                      % (Domain) + resoponse_record_json["status"]["message"] + "\033[0m")

                error_message = "域名:%s,添加失敗,錯誤信息:" \
                                % (Domain) + resoponse_record_json["status"]["message"] + "."

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = error_message + '\n'
                    file.writelines(line)
            for Sub_Domian in Sub_Domian_List:
                r = requests.post(self.Add_Record_URL, data={'login_token': self.Login_Token,
                                                        'format': self.Format,
                                                        'domain': Domain,
                                                        'sub_domain': Sub_Domian,
                                                        'record_type': Record_Type,
                                                        'record_line': Record_Line_value,
                                                        'value': Value,
                                                        })
                resoponse_record_json = r.json()
                if resoponse_record_json["status"]["code"] == "1":
                    print("域名:\033[34m%s\033[0m,添加:\033[34m" % (Domain) +
                          resoponse_record_json["record"]["name"] + "\033[0m,記錄成功.")

                    successful_message = "域名:%s,添加:" % (Domain) + \
                                         resoponse_record_json["record"]["name"] + ",記錄成功."

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = successful_message + '\n'
                        file.writelines(line)
                else:
                    print("域名:\033[31m%s\033[0m,添加:\033[31m%s\033[0m,記錄失敗,錯誤信息:\033[31m"
                          % (Domain, Sub_Domian) + resoponse_record_json["status"]["message"] + "\033[0m。")

                    error_message = "域名:%s,添加:%s,記錄失敗,錯誤信息:" \
                                    % (Domain, Sub_Domian) + resoponse_record_json["status"]["message"] + "。"

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = error_message + '\n'
                        file.writelines(line)

class Dns_Del_Domain(Global_Var):
    '''刪除域名'''
    def Del_Domain(self,Domains_List):
        '''刪除域名'''
        for Domain in Domains_List:
            r = requests.post(self.Del_Domain_URL,data={'login_token':self.Login_Token,
                                                        'format':self.Format,
                                                        'domain':Domain,
                                                        })
            resoponse_record_json = r.json()
            if resoponse_record_json["status"]["code"] == "1":
                print("刪除域名:\033[34m%s\033[0m,成功" %(Domain))

                successful_message = "刪除域名:%s,成功" %(Domain)

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = successful_message + '\n'
                    file.writelines(line)
            else:
                print("刪除域名:\033[31m%s失敗\033[0m,錯誤信息:\033[31m"
                      % (Domain) + resoponse_record_json["status"]["message"] + "\033[0m。")

                error_message = "刪除域名:%s失敗,錯誤信息:" % (Domain) + \
                                resoponse_record_json["status"]["message"] + "。"

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = error_message + '\n'
                    file.writelines(line)

class Dns_Add_Record(Global_Var):
    '''添加解析記錄'''
    def Add_Record(self,Domains_List,Sub_Domian_List,Record_Type,Record_Line_value,Value):
        '''添加域名和解析記錄'''
        for Domain in Domains_List:
            for Sub_Domian in Sub_Domian_List:
                r = requests.post(self.Add_Record_URL, data={'login_token': self.Login_Token,
                                                        'format': self.Format,
                                                        'domain': Domain,
                                                        'sub_domain': Sub_Domian,
                                                        'record_type': Record_Type,
                                                        'record_line': Record_Line_value,
                                                        'value': Value,
                                                        })
                resoponse_record_json = r.json()
                if resoponse_record_json["status"]["code"] == "1":
                    print("域名:\033[34m%s\033[0m,添加:\033[34m" % (Domain) +
                          resoponse_record_json["record"]["name"] + "\033[0m,記錄成功")

                    successful_message = "域名:%s,添加:" % (Domain) + \
                                         resoponse_record_json["record"]["name"] + ",記錄成功"

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = successful_message + '\n'
                        file.writelines(line)
                else:
                    print("域名:\033[31m%s\033[0m,添加:\033[31m%s\033[0m,記錄失敗,錯誤信息:\033[31m"
                          % (Domain, Sub_Domian) + resoponse_record_json["status"]["message"] + "\033[0m.")

                    error_message = "域名:%s,添加:%s,記錄失敗,錯誤信息:" % (Domain, Sub_Domian) + \
                                    resoponse_record_json["status"]["message"] + "."

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = error_message + '\n'
                        file.writelines(line)

class Dns_Alter_Record(Global_Var):
    '''修改解析記錄'''
    def Get_Record(self,Domains_List):
        '''獲取記錄ID'''
        for Domian in Domains_List:
            r = requests.post(self.Get_Record_URL,data={'login_token':self.Login_Token,
                                                        'format':self.Format,
                                                        'domain':Domian,
                                                        })

            resoponse_record_json = r.json()
            if resoponse_record_json['status']['code'] == '1':
                print("域名:\033[34m" + resoponse_record_json['domain']['name'] +
                      "\033[0m,共有:\033[34m" + resoponse_record_json['info']['sub_domains'] +
                      "\033[0m個子域名和:\033[34m" + resoponse_record_json['info']['record_total'] +
                      "\033[0m條解析記錄.")

                Get_Domain_Info = "域名:" + resoponse_record_json['domain']['name'] + \
                                  ",共有:" + resoponse_record_json['info']['sub_domains'] + \
                                  "個子域名和:" + resoponse_record_json['info']['record_total'] + "條解析記錄."

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = Get_Domain_Info + "\n\t 結果如下: " + '\n'
                    file.writelines(line)

                print("\t 結果如下:")
                for record in resoponse_record_json['records']:
                    Record_Type = record['type']
                    Record_Name = record['name']
                    Record_Value = record['value']
                    Record_ID = record['id']
                    print("\t\t 記錄類型:\033[34m" + Record_Type +
                          "\033[0m\t\t 子域名:\033[34m" + Record_Name +
                          "\033[0m\t\t 記錄值:\033[34m" + Record_Value +
                          "\033[0m\t\t\t\t 記錄ID:\033[34m" + Record_ID + "\033[0m")

                    Get_Record_Info = "\t\t 記錄類型:%s \t\t 子域名:%s \t\t 記錄值:%s \t\t\t\t 記錄ID:%s" \
                                      % (Record_Type, Record_Name, Record_Value, Record_ID)

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = Get_Record_Info + "\n"
                        file.writelines(line)
                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = "\n"
                    file.writelines(line)
            print("\n")

    def Alter_Record(self,Records_List,Change,Change_TO,Value):
        '''修改解析記錄'''
        if Value == '':
            for Record in Records_List:
                r = requests.post(self.Alter_Record_URL,data={'login_token': self.Login_Token,
                                                               'format': self.Format,
                                                               'record_id': Record,
                                                               'change': Change,
                                                               'change_to': Change_TO,
                                                               })
                resoponse_record_json = r.json()
                if resoponse_record_json['status']['code'] == '1':
                    print("域名:\033[34m" + resoponse_record_json['detail'][0]['domain'] +
                          "\033[0m,修改字段:\033[34m%s\033[0m 為 \033[34m%s\033[0m,成功。"%(Change,Change_TO))

                    successful_message = "域名:" + resoponse_record_json['detail'][0]['domain'] + \
                                         ",修改字段:%s 為 %s,成功。"%(Change,Change_TO)

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = successful_message + '\n'
                        file.writelines(line)
                else:
                    print("記錄ID:\033[31m%s\033[0m,修改字段:\033[31m%s\033[0m 為 \033[31m%s\033[0m,失敗,"
                          "錯誤信息:\033[31m"%(Record,Change,Change_TO) +
                          resoponse_record_json['status']['message'] + "\033[0m。")

                    error_message = "記錄ID:%s,修改字段:%s 為 %s,失敗,錯誤信息:" %(Record,Change,Change_TO) + \
                                    resoponse_record_json['status']['message'] + "。"

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = error_message + '\n'
                        file.writelines(line)

        else:
            for Record in Records_List:
                r = requests.post(self.Alter_Record_URL,data={'login_token':self.Login_Token,
                                                              'format':self.Format,
                                                              'record_id':Record,
                                                              'change':Change,
                                                              'change_to':Change_TO,
                                                              'value':Value,
                                                              })
                resoponse_record_json = r.json()
                if resoponse_record_json['status']['code'] == '1':
                    print("域名:\033[34m" + resoponse_record_json['detail'][0]['domain'] +
                          "\033[0m,將字段 \033[34m%s\033[0m 修改為 \033[34m%s\033[0m字段,值為:\033[34m%s\033[0m,成功。"
                          %(Change,Change_TO,Value))

                    successful_message = "域名:" + resoponse_record_json['detail'][0]['domain'] + \
                                         ",將字段 %s 修改為 %s字段,值為:%s,成功。"%(Change,Change_TO,Value)

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = successful_message + '\n'
                        file.writelines(line)
                else:
                    print("記錄ID:\033[31m%s\033[0m,將字段 \033[31m%s\033[0m 修改為 \033[31m%s\033[0m,"
                          "值為:\033[31m%s\033[0m,失敗,錯誤信息:\033[31m"%(Record,Change,Change_TO,Value) +
                          resoponse_record_json['status']['message'] + "\033[0m。")

                    error_message = "記錄ID:%s,將字段 %s 修改為 %s,值為:%s,失敗,錯誤信息:" \
                                    %(Record,Change,Change_TO,Value) + resoponse_record_json['status']['message'] + \
                                    "。"
                    print(error_message)
                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = error_message + '\n'
                        file.writelines(line)

class Dns_Del_Record(Global_Var):
    '''刪除解析記錄'''
    def Get_Record(self,Domains_List):
        '''獲取記錄ID'''
        for Domian in Domains_List:
            r = requests.post(self.Get_Record_URL,data={'login_token':self.Login_Token,
                                                        'format':self.Format,
                                                        'domain':Domian,
                                                        })

            resoponse_record_json = r.json()
            if resoponse_record_json['status']['code'] == '1':
                print("域名:\033[34m" + resoponse_record_json['domain']['name'] +
                      "\033[0m,共有:\033[34m" + resoponse_record_json['info']['sub_domains'] +
                      "\033[0m個子域名和:\033[34m" + resoponse_record_json['info']['record_total'] +
                      "\033[0m條解析記錄.")

                Get_Domain_Info = "域名:" + resoponse_record_json['domain']['name'] +",共有:" + \
                                  resoponse_record_json['info']['sub_domains'] + "個子域名和:" + \
                                  resoponse_record_json['info']['record_total'] + "條解析記錄."

                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = Get_Domain_Info + "\n\t 結果如下: " + '\n'
                    file.writelines(line)

                print("\t 結果如下:")
                for record in resoponse_record_json['records']:
                    Record_Type = record['type']
                    Record_Name = record['name']
                    Record_Value = record['value']
                    Record_ID = record['id']
                    print("\t\t 記錄類型:\033[34m" + Record_Type +
                          "\033[0m\t\t 子域名:\033[34m" + Record_Name +
                          "\033[0m\t\t 記錄值:\033[34m" + Record_Value +
                          "\033[0m\t\t\t\t 記錄ID:\033[34m" + Record_ID + "\033[0m")

                    Get_Record_Info = "\t\t 記錄類型:%s \t\t 子域名:%s \t\t 記錄值:%s \t\t\t\t 記錄ID:%s" \
                                      % (Record_Type, Record_Name, Record_Value, Record_ID)

                    with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                        line = Get_Record_Info + "\n"
                        file.writelines(line)
                with open(self.Response_record_file, 'a+', encoding='utf-8') as file:
                    line = "\n"
                    file.writelines(line)
            print("\n")

    def Del_Record(self,Domains_Records_List):
        '''刪除解析記錄'''
        for Domain_Record in Domains_Records_List:
            Domain = Domain_Record.split(sep='=')[0]
            Record = Domain_Record.split(sep='=')[1]
            r = requests.post(self.Del_Record_URL,data={'login_token':self.Login_Token,
                                                        'format':self.Format,
                                                        'domain':Domain,
                                                        'record_id':Record,
                                                        })
            resoponse_record_json = r.json()
            if resoponse_record_json['status']['code'] == '1':
                print("您正在刪除域名:\033[34m%s\033[0m,的解析記錄,記錄ID為:\033[34m%s\033[0m,刪除狀態值為:\033[34m"
                      %(Domain,Record) + resoponse_record_json['status']['code'] +
                      "\033[0m,信息為:\033[34m" + resoponse_record_json['status']['message'] +
                      "\033[0m。" + "\n")

                Get_Message = "您正在刪除域名:%s,的解析記錄,記錄ID為:%s,刪除狀態值為:" % (Domain, Record) + \
                              resoponse_record_json['status']['code'] + ",信息為:" + \
                              resoponse_record_json['status']['message'] + "。" + "\n"
            else:
                print("您正在刪除域名:\033[31m%s\033[0m,的解析記錄,記錄ID為:\033[31m%s\033[0m,刪除狀態值為:\033[31m"
                      %(Domain,Record) + resoponse_record_json['status']['code'] +
                      "\033[0m,信息為:\033[31m" + resoponse_record_json['status']['message'] +
                      "\033[0m。" + "\n")

                Get_Message = "您正在刪除域名:%s,的解析記錄,記錄ID為:%s,刪除狀態值為:" % (Domain, Record) + \
                              resoponse_record_json['status']['code'] + ",信息為:" + \
                              resoponse_record_json['status']['message'] + "。" + "\n"

            with open(self.Response_record_file,'a+',encoding='utf-8') as file:
                line = "\t" + Get_Message
                file.writelines(line)

class Dns_Get_Domain_List(Global_Var):
    '''獲取域名列表'''
    def Get_Domain_List(self):
        '''獲取域名列表'''
        r = requests.post(self.Get_Domain_List_URL,data={'login_token':self.Login_Token,
                                                         'format':self.Format})
        resoponse_record_json = r.json()
        Get_Message = "域名獲取狀態為:\033[34m" + str(resoponse_record_json['status']['code']) +\
                      "\033[0m,共有 \033[34m" + str(resoponse_record_json['info']['domain_total']) + \
                      " \033[0m個域名。"
        print(Get_Message)
        for Domains_List in resoponse_record_json['domains']:
            Domain_Id = Domains_List['id']
            Domain_Status = Domains_List['status']
            Domain_Status_DICT = {"enable": "正常", "pause": "已暫停解析", "spam": "已被封禁", "lock": "已被鎖定"}
            Domain = Domains_List['name']
            Domain_Records_Num = Domains_List['records']
            if Domain_Status == 'enable':
                print("域名:\033[34m%s\033[0m,\t域名ID:\033[34m%s\033[0m,\t域名狀態:"
                      "\033[34m%s\033[0m,\t域名解析記錄共:\033[34m%s\033[0m條。"
                      %(Domain,Domain_Id,Domain_Status_DICT[Domain_Status],Domain_Records_Num))

                INFO = "域名:%s,\t域名ID:%s,\t域名狀態:%s,\t域名解析記錄共:%s條。" \
                       %(Domain,Domain_Id,Domain_Status_DICT[Domain_Status],Domain_Records_Num)

            else:
                print("域名:\033[31m%s\033[0m,\t域名ID:\033[31m%s\033[0m,\t域名狀態:"
                      "\033[31m%s\033[0m,\t域名解析記錄共:\033[31m%s\033[0m條。"
                      %(Domain,Domain_Id,Domain_Status_DICT[Domain_Status],Domain_Records_Num))
                INFO = "域名:%s,\t域名ID:%s,\t域名狀態:%s,\t域名解析記錄共:%s條。" \
                       % (Domain, Domain_Id, Domain_Status_DICT[Domain_Status], Domain_Records_Num)
            with open(self.Response_record_file,'a+',encoding='utf-8') as file:
                line = INFO + "\n"
                file.writelines(line)

  1. 第二個python文件【 Second_Grade.py】,這是二級類和函數

    from First_Grade import *
    class Procedure(Global_Var):
    
    def Add_Domain_And_Record(self):
        '''添加域名和解析記錄'''
        Domains = input("請輸入您要添加的域名,用逗號分隔:")
        Sub_Domians = input("請輸入需要添加的子域名,用逗號分隔(不添加則回車):")
        Domains_List = Domains.split(sep=',')
        running = Dns_Add_Domain_Record(self.Login_Token)
        if Sub_Domians == '':
            running.Add_Domain(Domains_List)
        else:
            Record_Type = input("選擇記錄類型,輸入(   A  或  CNAME ):")
            Value = input("請輸入要解析的記錄值:")
            Record_Line = input("輸入記錄線路,回車默認:")
            if Record_Line == '':
                Record_Line_value = '默認'
            else:
                Record_Line_value = Record_Line
            Sub_Domian_List = Sub_Domians.split(sep=',')
            running.Add_Record(Domains_List,Sub_Domian_List,Record_Type,Record_Line_value,Value)
    
    def Del_Domain(self):
        '''刪除域名'''
        Domains = input("請輸入您需要刪除的域名,用逗號分隔:")
        Domains_List = Domains.split(sep=',')
        running = Dns_Del_Domain(self.Login_Token)
        running.Del_Domain(Domains_List)
    
    def Add_Record(self):
        '''添加解析記錄'''
        Domains = input("請輸入您需要添加解析記錄的域名,用逗號分隔:")
        Sub_Domians = input("請輸入需要添加的子域名,用逗號分隔:")
        Domains_List = Domains.split(sep=',')
        running = Dns_Add_Record(self.Login_Token)
        Record_Type = input("選擇記錄類型,輸入(   A  或  CNAME ):")
        Value = input("請輸入要解析的記錄值:")
        Record_Line = input("輸入記錄線路,回車默認:")
        if Record_Line == '':
            Record_Line_value = '默認'
        else:
            Record_Line_value = Record_Line
        Sub_Domian_List = Sub_Domians.split(sep=',')
        running.Add_Record(Domains_List,Sub_Domian_List,Record_Type,Record_Line_value,Value)
    
    def Alter_Record(self):
        '''修改記錄'''
        Domains = input("請輸入您需要修改解析記錄的域名,以便獲取其子域名的記錄ID,用逗號分隔:")
        Domains_List = Domains.split(sep=',')
        running = Dns_Alter_Record(self.Login_Token)
        running.Get_Record(Domains_List)
        Records = input("請找到需要修改的解析記錄的ID,并且輸入ID,用逗號分隔:")
        Records_List = Records.split(sep=',')
        Change = input("請輸入您要修改的字段([sub_domain,record_type,area,value,mx,ttl,status]):")
        Change_TO = input("請輸入,要修改為:")
        if Change == 'value':
            running.Alter_Record(Records_List, Change, Change_TO,Value='')
        else:
            Value = input("請輸入要修改到的記錄值:")
            running.Alter_Record(Records_List,Change,Change_TO,Value)
    
    def Del_Record(self):
        '''刪除記錄'''
        Domains = input("請輸入您需要刪除解析記錄的域名,以便獲取其子域名的記錄ID,用逗號分隔:")
        Domains_List = Domains.split(sep=',')
        running = Dns_Del_Record(self.Login_Token)
        running.Get_Record(Domains_List)
        Records = input("請輸入需要刪除的 域名ID 和 解析記錄ID,(格式, baidu.com=366663508,sion.com=366663502):")
        Domains_Records_List = Records.split(sep=',')
        running.Del_Record(Domains_Records_List)
    
    def Get_Domain_List(self):
        '''獲取域名列表'''
        running =  Dns_Get_Domain_List(self.Login_Token)
        running.Get_Domain_List()

  1. 第三個python文件【setup.py】,使用時執行此文件即可.
from Second_Grade import Procedure

Login_Token = '60234,c98937c63xxxxxxxxxxfadd4b7589065'

choose = input("\t\t \033[4m功能說明\033[0m\n\n"
               "\t\033[34m1\033[0m \t添加域名和解析記錄\n"
               "\t\033[34m2\033[0m \t刪除域名\n"
               "\t\033[34m3\033[0m \t添加解析記錄\n"
               "\t\033[34m4\033[0m \t修改解析記錄\n"
               "\t\033[34m5\033[0m \t刪除解析記錄\n"
               "\t\033[34m6\033[0m \t獲取域名列表\n\n"
               "請輸入您要操作任務的序號:")

Setup_DICT = {'1':'running.Add_Domain_And_Record()',
        '2':'running.Del_Domain()',
        '3':'running.Add_Record()',
        '4':'running.Alter_Record()',
        '5':'running.Del_Record()',
        '6':'running.Get_Domain_List()'}

running = Procedure(Login_Token)

exec(Setup_DICT[choose])

  1. 第四個python文件【README.py】,使用前請查看這個文件,里面有部分說明

###################  使用方法

'''
1. 建議使用python3.X
2. 需要安裝requests模塊
3. 為了方便多次使用;變量"login_token"直接寫在setup.py文件
4. 執行setup.py文件,然后選擇您需要進行的操作,根據提示進行
'''

#################  login_token的說明
API Token 生成方法詳見:https://support.dnspod.cn/Kb/showarticle/tsid/227/,完整的 API Token 是由 ID,Token 組合而成的,用英文的逗號分割。

###################  文件簡介

'''
First_Grade.py          一級類:底層對象
Second_Grade.py         二級類:二級對象
setup.py                執行文件
record_log.txt          日志文件

'''

##################### setup.py 字典簡介

'''
Setup_DICT = {'1':'running.Add_Domain_And_Record()',
        '2':'running.Del_Domain()',
        '3':'running.Add_Record()',
        '4':'running.Alter_Record()',
        '5':'running.Del_Record()',
        '6':'running.Get_Domain_List()'}
'''

'''添加域名和解析記錄'''
#running = Procedure(Login_Token)
#running.Add_Domain_And_Record()

'''刪除域名'''
#running = Procedure(Login_Token)
#running.Del_Domain()

'''添加解析記錄'''
#running = Procedure(Login_Token)
#running.Add_Record()

'''修改解析記錄'''
#running = Procedure(Login_Token)
#running.Alter_Record()

'''刪除解析記錄'''
#running = Procedure(Login_Token)
#running.Del_Record()

'''獲取域名列表'''
#running = Procedure(Login_Token)
#running.Get_Domain_List()

##################### 通用參數

#Login_Token = '59730,9929425701e799a72df32cb04855cf3d'
#Format = 'json'
#Response_record_file = 'record.txt'

#####################  API

'''

self.Add_Domain_URL = 'https://dnsapi.cn/Domain.Create'           # 添加域名
self.Del_Domain_URL = 'https://dnsapi.cn/Domain.Remove'           # 刪除域名
self.Add_Record_URL = 'https://dnsapi.cn/Record.Create'           # 添加記錄
#self.Alter_Record_URL = 'https://dnsapi.cn/Record.Modify'      #修改記錄
self.Alter_Record_URL = 'https://dnsapi.cn/Batch.Record.Modify'   # 批量修改記錄
self.Get_Record_URL = 'https://dnsapi.cn/Record.List'             # 獲取記錄列表
self.Del_Record_URL = 'https://dnsapi.cn/Record.Remove'           # 刪除記錄
self.Get_Domain_List_URL = 'https://dnsapi.cn/Domain.List'        # 獲取域名列表

'''

################### 參數解析

#子域名                    Sub_Domian
#記錄類型                  Record_Type
#記錄線路                  Record_Line
#解析記錄值                Value

#域名                    domain
#記錄ID                  record_id
#子域名                  sub_domain
#記錄值                  value
#記錄類型                record_type
#記錄線路                record_line
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

和田市| 大荔县| 霍林郭勒市| 望谟县| 磴口县| 永清县| 彰化县| 大关县| 民权县| 松江区| 甘德县| 易门县| 临泉县| 谢通门县| 孙吴县| 贡觉县| 九江县| 台南市| 永定县| 巫溪县| 吉林省| 遂宁市| 新民市| 且末县| 凌源市| 嘉善县| 井冈山市| 顺昌县| 舞阳县| 浠水县| 商河县| 广东省| 固始县| 滨海县| 普兰店市| 江孜县| 德兴市| 达日县| 合川市| 邓州市| 马公市|