aboutsummaryrefslogtreecommitdiff
path: root/domain.py
diff options
context:
space:
mode:
Diffstat (limited to 'domain.py')
-rwxr-xr-xdomain.py17
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]