28 lines
644 B
Python
28 lines
644 B
Python
#!/usr/bin/env python3
|
|
|
|
import urllib.request as request
|
|
import re
|
|
|
|
HOSTS = "https://someonewhocares.org/hosts/zero/hosts"
|
|
OUTPUT = "config/hostnames_remove.yml"
|
|
|
|
|
|
def main():
|
|
with request.urlopen(HOSTS) as i:
|
|
with open(OUTPUT, "w+") as o:
|
|
print(
|
|
*sorted(
|
|
[
|
|
rf"- '(.*\.)?{re.escape(l.split()[1])}$'"
|
|
for l in i.read().decode("utf-8").split("\n")
|
|
if l.startswith("0")
|
|
]
|
|
),
|
|
sep="\n",
|
|
file=o,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|