コード例 #1
0
def isDeepLevelSubdomain(url: str) -> int:
    """
    Return the no. of levels of subdomain of the given url
    e.g. abcbank.com.somedomain.com returns 2
    """
    domain = utils.getDomainFromUrl(url)
    return utils.getSubdomainFromDomain(domain).count('.') + 1
コード例 #2
0
 def test2leveldotcomdothk(self):
     self.assertEqual(utils.getSubdomainFromDomain('a.b.c.com.hk'), 'a.b')
コード例 #3
0
 def test1leveldotcom(self):
     self.assertEqual(utils.getSubdomainFromDomain('a.b.com'), 'a')