Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def load_domains():
# start an empty array
domains = []
# A little status information for us
print "[] Loading domains"
# We want our code to platform neutral, so use os.path.join
# to get to our data directory and extract out domains
file_location = os.path.join('data','domains.txt')
# First check to see if the file is actually there
if os.path.isfile(file_location):
# Open the file and ready each line
with open(file_location) as f:
for domain in f.readlines():
# lets strip out newline characters + lower them
dom =domain.strip('\n').strip('\r').lower()
# At the end lets provide a status that
# tells us how many domains we got
print "[x] %s Domains Loaded" % len(domains)
print '][ Failed to load domains, File not found'
# return to new array of domains
return domains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment