def clean_text(self, domain, **kwargs):
        """Try to extract only the domain bit from the """
        try:
            # handle URLs by extracting the domain name
            domain = urlparse(domain).hostname or domain
            domain = domain.lower()
            # get rid of port specs
            domain = domain.rsplit(':', 1)[0]
            domain = domain.rstrip('.')
            # handle unicode
            domain = domain.encode("idna").decode('ascii')
        except ValueError:
            return None
        if self.validate(domain):
            return domain
Try to extract only the domain bit from the