1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- """
- @Contact : liuyuqi.gov@msn.cn
- @Time : 2024/04/26
- @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
- @Desc : 域名工具
- """
- import whois
- from concurrent.futures import ThreadPoolExecutor
- class DomainUtil(object):
- """域名工具"""
- def __init__(self):
- super(DomainUtil,self).__init__()
-
- @staticmethod
- def get_expiration_date(domain:str)->None:
- '''
- 检测域名是否快到期
- :params domain 域名:
- :return true or false'''
- try:
- whi = whois.whois(domain)
- expirationDate= whi.expiration_date
- return expirationDate
- except Exception as e:
- print(e)
- return None
- @staticmethod
- def is_available(domain: str)->None:
- '''
- 检测域名是否可用
- :params domain 域名:
- :return true or false'''
- try:
- whi = whois.whois(domain)
- return False
- except Exception as e:
- if(str(e).index("No match") == 0):
- return True
- else:
- return False
|