For example, the base url of uk.reuters.com => reuters.com
(url)
| 61 | |
| 62 | |
| 63 | def 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 | |
| 76 | class ExhaustiveFullTextCase(unittest.TestCase): |
no test coverage detected
searching dependent graphs…