MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / get_domain_name

Function get_domain_name

web_programming/emails_from_url.py:47–56  ·  view source on GitHub ↗

This function get the main domain name >>> get_domain_name("https://a.b.c.d/e/f?g=h,i=j#k") 'c.d' >>> get_domain_name("Not a URL!") ''

(url: str)

Source from the content-addressed store, hash-verified

45
46# Get main domain name (example.com)
47def get_domain_name(url: str) -> str:
48 """
49 This function get the main domain name
50
51 >>> get_domain_name("https://a.b.c.d/e/f?g=h,i=j#k")
52 'c.d'
53 >>> get_domain_name("Not a URL!")
54 ''
55 """
56 return ".".join(get_sub_domain_name(url).split(".")[-2:])
57
58
59# Get sub domain name (sub.example.com)

Callers 1

emails_from_urlFunction · 0.85

Calls 2

get_sub_domain_nameFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected