Created
November 30, 2017 16:34
-
-
Save mrozo/081a3c383706c8dba3ef8d6e9daf11b6 to your computer and use it in GitHub Desktop.
Convert blacklist of no coin chrome extension int a hosts file entry. https://github.com/keraf/NoCoin
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 re | |
blacklist = open("/home/mroz/workspace/coin-hoster/blacklist.txt",'r') | |
domains = set() | |
wildcards = set() | |
domain_matcher = re.compile("[^/]+//(\*\.)?(?P<domain>[^/]+)") | |
for line in blacklist: | |
try: | |
domains.add(domain_matcher.match(line).groupdict()['domain']) | |
except: | |
pass | |
print(domains) | |
hosts_file = map(lambda d: "0.0.0.0 " + d, domains) | |
hosts_file = "\n".join(hosts_file) | |
print(hosts_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment