aboutsummaryrefslogtreecommitdiff
path: root/domain.py
blob: 9f39efc630fa5aedd5205b61b534bfaa08169ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python

def url_extract_domain(url):
    index = 0
    if url.startswith("http://"):
        index += 7
    elif url.startswith("https://"):
        index += 8

    if url.startswith("www.", index):
        index += 4

    end = url.find(".", index)
    if end == -1:
        return url[index:]
    else:
        return url[index:end]