MCPcopy
hub / github.com/codelucas/newspaper / get_base_domain

Function get_base_domain

tests/unit_tests.py:63–73  ·  view source on GitHub ↗

For example, the base url of uk.reuters.com => reuters.com

(url)

Source from the content-addressed store, hash-verified

61
62
63def get_base_domain(url):
64 """For example, the base url of uk.reuters.com => reuters.com
65 """
66 domain = get_domain(url)
67 tld = '.'.join(domain.split('.')[-2:])
68 if tld in ['co.uk', 'com.au', 'au.com']: # edge cases
69 end_chunks = domain.split('.')[-3:]
70 else:
71 end_chunks = domain.split('.')[-2:]
72 base_domain = '.'.join(end_chunks)
73 return base_domain
74
75
76class ExhaustiveFullTextCase(unittest.TestCase):

Callers 1

runTestMethod · 0.85

Calls 3

get_domainFunction · 0.90
joinMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…