diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-11-20 06:36:17 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:12:34 +0200 |
commit | d72ec3c5a20e2302b991c7bd60d39f7177bf2ec9 (patch) | |
tree | 886f4a116dde9d493d37c8c859b79b13a073ce04 /domain.py | |
parent | 472e0333c05207fef5cf13a0585a91fa78e233d9 (diff) |
Remove dependency on tldextract
Diffstat (limited to 'domain.py')
-rwxr-xr-x | domain.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/domain.py b/domain.py new file mode 100755 index 0000000..9f39efc --- /dev/null +++ b/domain.py @@ -0,0 +1,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] |