python module for nslookup

后端 未结 9 830
渐次进展
渐次进展 2020-12-10 00:27

Is there a python-module that\'s doing the same stuff as nslookup does? I am planning to use nslookup on digging some information regarding the domain of a URL to be scrappe

9条回答
  •  北海茫月
    2020-12-10 01:27

    You need to use DNSPython

    import dns.resolver
    
    answers = dns.resolver.query('dnspython.org', 'MX')
    for rdata in answers:
        print 'Host', rdata.exchange, 'has preference', rdata.preference
    

提交回复
热议问题