mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
模块优化
This commit is contained in:
@@ -12,6 +12,7 @@ class Search(Module):
|
||||
self.per_page_num = 50 # 每页显示搜索条数
|
||||
self.recursive_search = settings.enable_recursive_search
|
||||
self.recursive_times = settings.search_recursive_times
|
||||
self.full_search = settings.enable_full_search
|
||||
|
||||
@staticmethod
|
||||
def filter(domain, subdomain):
|
||||
@@ -50,3 +51,28 @@ class Search(Module):
|
||||
if not location:
|
||||
return set()
|
||||
return set(self.match_subdomains(location))
|
||||
|
||||
def check_subdomains(self, subdomains):
|
||||
"""
|
||||
检查搜索出的子域结果是否满足条件
|
||||
|
||||
:param subdomains: 子域结果
|
||||
:return:
|
||||
"""
|
||||
if not subdomains:
|
||||
# 搜索没有发现子域名则停止搜索
|
||||
return False
|
||||
if not self.full_search and subdomains.issubset(self.subdomains):
|
||||
# 在全搜索过程中发现搜索出的结果有完全重复的结果就停止搜索
|
||||
return False
|
||||
return True
|
||||
|
||||
def recursive_subdomain(self):
|
||||
# 递归搜索下一层的子域
|
||||
# 从1开始是之前已经做过1层子域搜索了,当前实际递归层数是layer+1
|
||||
for layer_num in range(1, self.recursive_times):
|
||||
for subdomain in self.subdomains:
|
||||
# 进行下一层子域搜索的限制条件
|
||||
count = subdomain.count('.') - self.domain.count('.')
|
||||
if count == layer_num:
|
||||
yield subdomain
|
||||
|
||||
Reference in New Issue
Block a user