Skip to content

Instantly share code, notes, and snippets.

@nickfox-taterli
Created April 10, 2023 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickfox-taterli/c1585906e26951d5fc8f1f5456403e6a to your computer and use it in GitHub Desktop.
Save nickfox-taterli/c1585906e26951d5fc8f1f5456403e6a to your computer and use it in GitHub Desktop.
GenerateRecursorZone
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