优化代码结构 删除无用队列结果集参数

This commit is contained in:
shmilylty
2019-08-05 18:00:01 +08:00
parent 53213304e2
commit 11642edf6e
50 changed files with 332 additions and 502 deletions
+8 -15
View File
@@ -1,9 +1,8 @@
# coding=utf-8
import time
import queue
import config
from common.search import Search
from config import logger
class GoogleAPI(Search):
@@ -48,16 +47,13 @@ class GoogleAPI(Search):
if self.page_num > 100: # 免费的API只能查询前100条结果
break
def run(self, rx_queue):
def run(self):
"""
类执行入口
"""
if not (self.cx and self.key):
logger.log('ERROR', f'{self.source}模块API配置错误')
logger.log('ALERT', f'不执行{self.source}模块')
if not self.check(self.cx, self.key):
return
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
self.begin()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -74,21 +70,18 @@ class GoogleAPI(Search):
self.save_json()
self.gen_result()
self.save_db()
rx_queue.put(self.results)
logger.log('DEBUG', f'结束执行{self.source}模块搜索{self.domain}的子域')
self.finish()
def do(domain, rx_queue): # 统一入口名字 方便多线程调用
def do(domain): # 统一入口名字 方便多线程调用
"""
类统一调用入口
:param str domain: 域名
:param rx_queue: 结果集队列
"""
search = GoogleAPI(domain)
search.run(rx_queue)
search.run()
if __name__ == '__main__':
result_queue = queue.Queue()
do('example.com', result_queue)
do('example.com')