Created
September 25, 2017 09:21
-
-
Save VGostyuzhov/53e272fd2d575a7f80a1b09f72878044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import dns.resolver | |
resolver = dns.resolver.Resolver() | |
resolver.timeout = 5 | |
resolver.lifetime = 5 | |
if __name__ == '__main__': | |
source_file = sys.argv[1] | |
with open(source_file) as infile, open('result_MX.txt', 'wb') as outfile: | |
for domain in infile: | |
domain = domain.strip() | |
print('Getting MX records for: %s' % domain) | |
try: | |
answers = resolver.query(domain, 'mx') | |
outfile.write(domain + '\n') | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment