Created
February 22, 2012 08:20
-
-
Save nirleka/1883388 to your computer and use it in GitHub Desktop.
Parsing 4th level domain from file which contain domain
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
""" | |
host.txt generated from command: host -l domain (unix like) | |
""" | |
try: | |
f = open("host.txt", "r") | |
try: | |
lines = f.readlines() | |
before = "" | |
count = 0 | |
for line in lines: | |
domain = line[0:line.find(' ')] | |
if (domain != before): | |
if (domain.count('.') == 3): | |
count += 1 | |
print "{} : {}".format(domain, count) | |
before = domain | |
finally: | |
print count | |
f.close() | |
except IOError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment