Skip to content

Instantly share code, notes, and snippets.

@Psycojoker
Created December 21, 2016 20:10
Show Gist options
  • Select an option

  • Save Psycojoker/a71144e6ea991a88bd66b327a290da0f to your computer and use it in GitHub Desktop.

Select an option

Save Psycojoker/a71144e6ea991a88bd66b327a290da0f to your computer and use it in GitHub Desktop.
import re
hosts = open("/etc/hosts", "r").read()
# remove comments
hosts = re.sub("#.*[^\n]", "", hosts)
# split everywords
hosts = re.split("\s+", hosts)
hosts = map(lambda x: x.lower(), hosts)
if domain.lower() not in hosts:
# do stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment