import whois
def is_registered(domain_name):
"""
A function that returns a boolean indicating
whether a `domain_name` is registered
"""
try:
w = whois.whois(domain_name)
except Exception:
return False
else:
return bool(w.domain_name)
domains = [
"도메인1.com",
"도메인2.net",
"도메인3.com",
"도메인4.com"
]
for domain_name in domains:
if is_registered(domain_name):
whois_info = whois.whois(domain_name)
# get expiration date
print(domain_name," : Expiration date:", whois_info.expiration_date)
pip install python-whois 설치해야 함.