优化域名获取

This commit is contained in:
Jing Ling
2020-04-08 21:58:30 +08:00
parent 74f7077c51
commit dd7935b69c
+11 -7
View File
@@ -124,15 +124,19 @@ def get_domains(target):
elif isinstance(target, list): elif isinstance(target, list):
domains = target domains = target
elif isinstance(target, str): elif isinstance(target, str):
path = Path(target) target = target.lower().strip()
if path.is_file(): domain = Domain(target).match()
with open(target, encoding='utf-8', errors='ignore') as file: if domain:
for line in file: domains.append(domain)
domain = Domain(line.strip()).match() else:
path = Path(target)
if path.is_file() and path.exists():
with open(target, encoding='utf-8', errors='ignore') as file:
for line in file:
line = line.lower().strip()
domain = Domain(line).match()
if domain: if domain:
domains.append(domain) domains.append(domain)
elif Domain(target).match():
domains = [target]
count = len(domains) count = len(domains)
if count == 0: if count == 0:
logger.log('FATAL', f'获取到{count}个域名') logger.log('FATAL', f'获取到{count}个域名')