Save the Ali domain name configuration to the Execl file (which will be used later to the local database platform, etc.)

Source: Internet
Author: User

Tag:execl    read domain name     file    

#!/usr/bin/env python#coding:utf-8import os , sysfrom time import  Strftimefrom sys import exitimport json ,refrom aliyunsdkcore.client import  acsclientfrom aliyunsdkalidns.request.v20150109 import describedomainsrequest, describedomainrecordsrequest,updatedomainrecordrequestfrom openpyxl import workbookimport  Urllibid= "Ltxxxw#ss85vcth" secret= "rdamykkb82kpw4ublsynuun7n" regionid= "cn-beijing"  client =  Acsclient (Id,secret,regionid) def getlogin ():    req =  Describedomainsrequest.describedomainsrequest ()      #status,  headers, body =  client.get_response (req)      #status,  headers, body = client.do_ Action_with_exception (acs_request=req)     body = client.do_action_with_exception (req)     print  (json.loads (body["Domains"]))     exit ()     if status == 200:         pat = re.compile (' <DomainName> (. *?) </DomainName> ')         domainname=re.findall (pat, body)         print (DomainName)          return domainname    else:        print (' unexpected errors: status=%d, error=%s '  %  (status, body)) def  Getdomainlist ():     domainlist = describedomainsrequest.describedomainsrequest ()     domainlist.set_accept_format (' json ')     try:         dnslistjson = json.loads (Client.do_action_with_exception (DomainList)) [ ' Domains ' [' Domain ']         #print (dnslistjson[' Domains ' [' Domain '])          domainnames=[]        for domain in dnslistjson:             domainnames.append (Domain[' DomainName ')          #print   (domainnames)          return DomainNames    except ValueError as e :         passdef getalldomainrecords (DomainName):     domainrecords = describedomainrecordsrequest.describedomainrecordsrequest ()      domainrecords.set_accept_format (' json ')     domainrecords.set_domainname (DomainName)     domainrecordsjson = json.loads (Client.do_action_with_exception (DomainRecords ))     for x in domainrecordsjson[' domainrecords ' [' Record ']:         #print (x)         pass    return  domainrecordsjson[' domainrecords ' [' Record ']def writeexeclpy (filename,records,worktable= ' Sheet1 '):     wb = workbook ()     sheet = wb.active     sheet.title = str (worktable)     title=list (Records[0].keys ())      for m in range (0,len (title)):         #print   (Title[m])         sheet.cell (Row=1, column=int (m+1)). value =  '%s '  %  (Title[m])     i = 2     table = {}    for record in records:          #print  (record)         for m in range (0, len (title)):             sheet.cell (Row=i, column=int (M  + 1) .value =  '%s '  %  (Record[title[m])          i=i+1    wb.save (FileName) def test ():    passif  __name__ ==  ' __main__ ':     getdomainlist ()     records= Getalldomainrecords (' itxxx.cc ')     filename = r '/tmp/execl_test10.xlsx '       #print (Records)     writeexeclpy (Filename=filename,records=records, Worktable=strftime ('%y-%m-%d '))


650) this.width=650; "title=" 1.jpg "alt=" F4292ba8c19f92608b3cba4a63e50d31.jpg-wh_ "src=" https://s4.51cto.com/oss/ 201711/06/f4292ba8c19f92608b3cba4a63e50d31.jpg-wh_500x0-wm_3-wmp_4-s_3191076991.jpg "/>

This article is from the "Urban Cloth" blog, please be sure to keep this source http://sunday208.blog.51cto.com/377871/1979232

Save the Ali domain name configuration to the Execl file (which will be used later to the local database platform, etc.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.