import dns.resolver
import concurrent.futures
domains=open('com 2021-6-7 domains.txt',encoding='utf-8').read().splitlines()[0:10000]
mx_domains=[]
def check(domain):
try:
answers = dns.resolver.resolve(domain, 'MX')
print('MX EXISTS')
mx_domains.append(domain)
except Exception as e:
print(e)
print('No MX')
with concurrent.futures.ThreadPoolExecutor(max_workers=500) as executor:
executor.map(check, domains)
为什么此代码给出错误:
The DNS operation timed out after 5.005800008773804 seconds
还有没有办法解决这个问题,或者可能有更好的方法来解决这个问题?还是与我的网络有关?我是网络领域的新手,所以我无法理解为什么这甚至会导致超时错误?