Created
April 10, 2023 04:22
-
-
Save nickfox-taterli/c1585906e26951d5fc8f1f5456403e6a to your computer and use it in GitHub Desktop.
GenerateRecursorZone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
domain = 'google' | |
def export_rule(file) -> list : | |
with open('./data/' + file,encoding='utf-8') as f: | |
# 所有域名列表 | |
ds = f.readlines() | |
for d in ds: | |
# 注释忽略 | |
if d.startswith('#'): | |
continue | |
# 太短忽略 | |
if len(d) < 3: | |
continue | |
if d.find('@') > 1: | |
d = d[:d.find('@') - 1] | |
# 二层包含 | |
if d.startswith('include:'): | |
export_rule(d.strip().replace('include:','')) | |
# 完整匹配 | |
elif d.startswith('full:'): | |
print(d.strip().replace('full:', '')) | |
# 正则规则(暂无处理,不知道有没有不良后果!) | |
elif d.startswith('regexp:'): | |
continue | |
else: | |
print(d.strip()) | |
export_rule(domain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment