dnspython

How do we get TXT, CNAME and SOA records from dnspython?

我的未来我决定 提交于 2019-12-03 02:24:56
I have a requirement to have a dns query function to query a server for various records. I figured out how to get the MX record (most of the examples show this), A record and NS record. How do I get the TXT, CNAME and SOA records? Sample code snippet: import dns.resolver answer=dns.resolver.query("google.com", "A") for data in answer: print data.address I tried replacing the query type with TXT and the data.address object with data.text, data.data etc, but ended up with attribute errors. What are the references for the data types I mentioned earlier? (To answer how you can figure out the

Dnspython: Setting query timeout/lifetime

馋奶兔 提交于 2019-12-01 15:50:33
I have a small script that checks a large list of domains for their MX records, everything works fine but when the script finds a domain with no record, it takes quite a long time to skip to the next one. I have tried adding: query.lifetime = 1.0 or query.timeout = 1.0 but this doesn't seem to do anything. Does anyone know how this setting is configured? My script is below, thanks for your time. import dns.resolver from dns.exception import DNSException import dns.query import csv domains = csv.reader(open('domains.csv', 'rU')) output = open('output.txt', 'w') for row in domains: try: domain =

Dnspython: Setting query timeout/lifetime

前提是你 提交于 2019-12-01 15:38:32
问题 I have a small script that checks a large list of domains for their MX records, everything works fine but when the script finds a domain with no record, it takes quite a long time to skip to the next one. I have tried adding: query.lifetime = 1.0 or query.timeout = 1.0 but this doesn't seem to do anything. Does anyone know how this setting is configured? My script is below, thanks for your time. import dns.resolver from dns.exception import DNSException import dns.query import csv domains =

Tell urllib2 to use custom DNS

99封情书 提交于 2019-11-27 03:36:20
I'd like to tell urllib2.urlopen (or a custom opener ) to use 127.0.0.1 (or ::1 ) to resolve addresses. I wouldn't change my /etc/resolv.conf , however. One possible solution is to use a tool like dnspython to query addresses and httplib to build a custom url opener. I'd prefer telling urlopen to use a custom nameserver though. Any suggestions? Looks like name resolution is ultimately handled by socket.create_connection . -> urllib2.urlopen -> httplib.HTTPConnection -> socket.create_connection Though once the "Host:" header has been set, you can resolve the host and pass on the IP address