将阿里域名配置保存到execl文件(后面将使用到本地数据库平台等)

#!/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>(.*?)</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 :
        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‘))

效果图:

时间: 2024-08-01 11:56:40

将阿里域名配置保存到execl文件(后面将使用到本地数据库平台等)的相关文章

转:ffmpeg学习(二) 通过rtsp获取H264裸流并保存到mp4文件

本篇将使用上节http://www.cnblogs.com/wenjingu/p/3977015.html中编译好的库文件通过rtsp获取网络上的h464裸流并保存到mp4文件中. 1.VS2010建立VC++  win32控制台项目 2.在工程目录下建立lib目录和include目录,将已编译好的lib拷打lib下,include拷到include下,dll拷到Debug目录下 3.工程属性--配置属性--VC++目录--包含目录,添加ffmpeg头文件目录及其他第三方头文件目录 链接器--常

VB.NET 将JSON格式的字符串保存到XML文件中

1.关于本文 这几天打算写一个工具类JsonXmlHelper,用来进行用XML来保存JSON格式文件的工作.该工具类中要实现2个最主要的函数: 1)将JSON格式的内容写入到地址为address的XML中:WriteJsonToXml 2)把函数1中构造的XML文件恢复成JSON格式文档:RecoverJsonFromXml 函数1的实现将在本文中给出,函数2的实现将在以后发表的博文中给出 2.代码说明 1)添加引用:Newtonsoft.Json.dll 2)导入库 'JSON解析相关函数,

JTextArea内容保存到txt文件上,如何实现换行

解决办法: 如果是采用流的方式一行一行写到文件中,可以把FileWriter换为PrintWriter,然后调用PrintWriter的println()方法. byte fileContent[] = getJTextArea().getText().replaceAll("\n", "\r\n").getBytes();//此处主要是为了在Windows中实现换行操作 FileWriter fw=new FileWriter(file); String str=

内核模块遍历进程和任务队列保存到proc文件中

实现一个模块用它遍历当前进程的父进程和任务队列,并将遍历的结果输出到一个proc 文件中(遍历可以从 current 当前进程开始,父进程遍历到初始化进程,遍历任务队列可以利用 for_each_process 宏). 下面是我的内核模块的实现部分: /************************************************************ * 使用内核模块从当前进程开始先前遍历,知道找到第一个进程为止 * * 并将遍历的结果保存到proc文件中 * ******

[matlab]改变矩阵的大小并保存到txt文件

要完成的任务是,加载一个保存在txt文件中的矩阵, 并把它扩大10倍,并且要再次保存回去 %加载txt文件 >load('Matrix.txt'); %扩大10倍 repmat(Matrix,row column) % 这里的matrix 参数是要对其进行修改的matrix, 其中row是要新建的一个矩阵的行数, 而column是新建矩阵的列数 >Matrix = repmat(Matrix,10,1); % 这个就相当于  将Matrix矩阵 复制了10份,并且是按列排列的, 等同于 Mat

关于爬取数据保存到json文件,中文是unicode解决方式

流程: 爬取的数据处理为列表,包含字典.里面包含中文, 经过json.dumps,保存到json文件中, 发现里面的中文显示未\ue768这样子 查阅资料发现,json.dumps 有一个参数.ensure_ascii =true,  它会将不是ascii字符的转义为json 字符串. 如果是false ,不是ascii字符的会包含在里面,即如果是中文就会保存中文. 但是我认为json这样写是有道理的. 用requests模块, requests.post(url,json=handled_da

np.savetxt()——将array保存到txt文件,并保持原格式

问题:1.如何将array保存到txt文件中?2.如何将存到txt文件中的数据读出为ndarray类型? 需求:科学计算中,往往需要将运算结果(array类型)保存到本地,以便进行后续的数据分析. 解决:直接用numpy中的方法. 1:numpy.savetxt(fname,X):第一个参数为文件名,第二个参数为需要存的数组(一维或者二维). 2.numpy.loadtxt(fname):将数据读出为array类型. 示例 >>> import numpy as np >>&

shell脚本每隔2s获取某个进程的cpu和mem数据并保存到csv文件

shell脚本每隔2s获取某个进程的cpu和mem数据并保存到csv文件 shell脚本如下echo "%CPU,%MEM" > cpu_test.csvpid=1 #Can be change by yourselfwhile true do top -bn1 -n 1 -p $pid | tail -1 | awk '{ print $9,$10 }' | sed 's/ /,/' >> cpu_test.csv sleep 2 #delay timedone 脚

Sql数据保存到Excel文件中

public string ExportExcel( DataSet ds,string saveFileName) { try { if (ds == null) return "数据库为空"; bool fileSaved = false; Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); if (xlApp == null) {