码迷,mamicode.com
首页 > 编程语言 > 详细

学习python自动化运维之模块域名解析方法详解

时间:2015-08-12 19:52:58      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:python   domain   please   记录   

1.MX

    

#!/usr/bin/env python


import dns.resolver


domain = raw_input(‘please input an domain: ‘)

MX = dns.resolver.query(domain, ‘MX‘)

for i in MX:

        print ‘MX preference =‘, i.preference, ‘mail exchanger =‘, i.exchange


2.NS

#/usr/bin/env python




import dns.resolver

domain = raw_input(‘please input an domain: ‘)

ns = dns.resolver.query(domain, ‘NS‘)

for i in ns.response.answer:

        for j in i.items:

                print j.to_text()


3.A记录

#!/usr/bin/env python


import dns.resolver

domain = raw_input(‘please input an domain: ‘)

A = dns.resolver.query(domain, ‘A‘)

for i in A.response.answer:

        for j in i.items:

                print j.address


4.CNAME

#!/usr/bin/env python


import dns.resolver


domain = raw_input(‘please input an domain: ‘)

cname = dns.resolver.query(domain, ‘CNAME‘)

for i in cname.response.answer:

        for j in i.items:

                print j.to_text()


学习python自动化运维之模块域名解析方法详解

标签:python   domain   please   记录   

原文地址:http://yzg784534398.blog.51cto.com/9719002/1684039

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!