searxng/generate_hostnames_remove.py
ange b00854e655
All checks were successful
/ deploy (push) Successful in 5s
bump: 2025.7.17-e851bc1
2025-07-18 17:34:04 +00:00

30 lines
710 B
Python

#!/usr/bin/env python3
import urllib.request as request
import re
URL = "https://someonewhocares.org/hosts/zero/hosts"
OUTPUT = "config/hostnames_remove.yml"
def main():
with request.urlopen(
request.Request(URL, headers={"User-Agent": "curl/8.15.0"})
) 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()