扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
#!/usr/bin/env python #coding:utf-8 import os , sys from time import strftime from sys import exit import json ,re from aliyunsdkcore.client import AcsClient from aliyunsdkalidns.request.v20150109 import DescribeDomainsRequest,DescribeDomainRecordsRequest,UpdateDomainRecordRequest from openpyxl import Workbook import urllib ID="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=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 : pass def 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(): pass if __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'))
效果图:
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、网络空间、营销软件、网站建设、灌云网站维护、网站推广。另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流