harshadyeola
10 years ago
2 changed files with 24 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||
from urllib.parse import urlparse |
|||
|
|||
|
|||
def validate_domain(url): |
|||
|
|||
# Check if http:// or https:// present remove it if present |
|||
domain_name = url.split('/') |
|||
if 'http:' in domain_name or 'https:' in domain_name: |
|||
domain_name = domain_name[2] |
|||
else: |
|||
domain_name = domain_name[0] |
|||
|
|||
www_domain_name = domain_name.split('.') |
|||
final_domain = '' |
|||
if www_domain_name[0] == 'www': |
|||
final_domain = '.'.join(www_domain_name[1:]) |
|||
return final_domain |
|||
else: |
|||
final_domain = domain_name |
|||
return final_domain |
Loading…
Reference in new issue