lqg 2 years ago
parent
commit
6894b4ddf8

+ 8 - 1
requirements.txt

@@ -1 +1,8 @@
-python-whois==0.8.0
+python-whois==0.8.0
+
+
+
+
+
+
+

+ 7 - 0
searchdomain/config.py

@@ -0,0 +1,7 @@
+class Config(object):
+    
+    def __init__(self):
+        pass
+
+if __name__ == "__main__":
+    pass

+ 9 - 0
searchdomain/db.py

@@ -5,13 +5,22 @@ class Db():
     '''Db接口'''
     '''Db接口'''
     def __init__(self):
     def __init__(self):
         pass
         pass
+    
     def save(domain:str, res:bool):
     def save(domain:str, res:bool):
         pass
         pass
 
 
 class File(Db):
 class File(Db):
+    '''文件保存结果'''
     def save(domain: str, res: bool):
     def save(domain: str, res: bool):
         return super().save(res)
         return super().save(res)
 
 
 class Mysql(Db):
 class Mysql(Db):
+    '''mysql数据库保存数据库'''
     def save(domain: str, res: bool):
     def save(domain: str, res: bool):
         return super().save(res)
         return super().save(res)
+
+class Sqlite(Db):
+    '''sqlite保存'''
+    def save(domain: str, res: bool):
+        return super().save(res)
+

+ 45 - 0
searchdomain/domain_notify.py

@@ -0,0 +1,45 @@
+import whois
+from concurrent.futures import ThreadPoolExecutor
+import os,sys,re,json
+# import requests
+
+class DomainNotify(object):
+    """域名到期推送"""
+    def __init__(self):
+        super(DomainNotify,self).__init__()
+    
+    def crawl(self, domain:str)->None:
+        '''
+        检测域名是否可用
+        :params domain 域名:
+        :return true or false'''
+        res=False
+        try:
+            whi = whois.whois(domain)
+            res= False
+        except Exception as e:
+            if(str(e).index("No match")==0):
+                res= True
+            else:
+                res= False
+        self.saveRes(domain,res)
+        self.notify(domain,res)
+    
+    def notify(self,domain):
+        '''结果推送'''
+        pass
+
+    def saveRes(damin:str, res:bool):
+        # mysql.save()
+        # file.save()
+        pass
+
+    def run(self):
+        with open("res/res.json","w",encoding="utf8") as file:
+            pool=ThreadPoolExecutor(max_workers=10)
+            for i in range(100):
+                pool.submit(self.crawl, domain)
+
+if __name__ == '__main__':
+    sd = DomainNotify()
+    sd.run()

+ 51 - 0
searchdomain/push.py

@@ -0,0 +1,51 @@
+from email.mime.text import MIMEText
+from email.utils import formataddr
+import smtplib
+
+class Push(object):
+    '''消息推送'''
+    def __init__(self):
+        pass
+    
+    def send(self, message:str):
+        '''you must implement it and send message'''
+        pass
+
+class SMSPush(Push):
+    '''短信推送'''
+    
+    def __init__(self):
+        pass
+    def send(self, message:str):
+        pass
+
+class EmailPush(Push):
+    '''邮件推送'''
+    
+    def __init__(self):
+        pass
+    def send(self, message:str):
+        mailserver = "smtp.yoqi.me"
+        username = "service@yoqi.me"
+        password = ""
+        msg = MIMEText("邮件内容")
+        msg['Subject'] = "测试主题"
+        msg['From'] = "service@yoqi.me"
+        msg['To'] = "xx@qq.com"
+        try:
+            s = smtplib.SMTP(mailserver)
+            s.login(username, password)
+            s.send_message(msg)
+            s.quit()
+        except Exception as e:
+            print(e)
+
+class AppPush(Push):
+    '''App推送'''
+    def __init__(self):
+        pass
+    def send(self, message:str):
+        pass
+
+if __name__ == "__main__":
+    pass

+ 5 - 3
searchdomain/searchdomain.py

@@ -2,12 +2,13 @@ import whois
 from concurrent.futures import ThreadPoolExecutor
 from concurrent.futures import ThreadPoolExecutor
 import os,sys,re,json
 import os,sys,re,json
 # import requests
 # import requests
-
+import logging
 class SearchDomain(object):
 class SearchDomain(object):
-    """docstring for SearchDomain"""
+    """search avaliable domain and save result"""
+
     def __init__(self):
     def __init__(self):
         super(SearchDomain,self).__init__()
         super(SearchDomain,self).__init__()
-
+    
     def crawl(self, domain:str)->None:
     def crawl(self, domain:str)->None:
         '''
         '''
         检测域名是否可用
         检测域名是否可用
@@ -30,6 +31,7 @@ class SearchDomain(object):
         pass
         pass
 
 
     def run(self):
     def run(self):
+        '''begin search domain'''
         with open("res/res.json","w",encoding="utf8") as file:
         with open("res/res.json","w",encoding="utf8") as file:
             pool=ThreadPoolExecutor(max_workers=10)
             pool=ThreadPoolExecutor(max_workers=10)
             for i in range(100):
             for i in range(100):