Ejemplo n.º 1
0
    def test_parseURLs(self):
        parser = URLParser()
        hostnames = parser.parseURLs("urls.txt")

        self.assertEqual(len(hostnames), 5)
        self.assertEqual(hostnames["twitter.com"], 3)
        self.assertEqual(hostnames["abcnews.go.com"], 2)
        self.assertEqual(hostnames["google.co.uk"], 1)
        self.assertEqual(hostnames["newsfeed.time.com"], 1)
        self.assertEqual(hostnames["world.time.com"], 1)
Ejemplo n.º 2
0
import argparse
from URLParser import URLParser

parser = argparse.ArgumentParser(
    description="Parse hostnames from a text file.")
parser.add_argument('file', help="A file containing hostnames")
args = parser.parse_args()

parser = URLParser()
hostnames = parser.parseURLs(args.file)
for hostname, count in parser.sortHostnames(hostnames):
    print(count, hostname)