code: def _is_domain_valid(self, url, tld):
          
  
          if not url:
              return False
  
          scheme_pos = url.find('://')
          if scheme_pos == -1:
              url = 'http://' + url
  
          url_parts = uritools.urisplit(url)
          # <scheme>://<authority>/<path>?<query>#<fragment>
  
          try:
              host = url_parts.gethost()
          except ValueError:
              self._logger.info(
                  "Invalid host '%s'. "
                  "If the host is valid report a bug.", url
              )
              return False
  
          if not host:
              return False
  
          host_parts = host.split('.')
          if len(host_parts) <= 1:
              return False
  
          host_tld = '.'+host_parts[-1]
          if host_tld != tld:
              return False
  
          top = host_parts[-2]
  
          if self._hostname_re.match(top) is None:
              return False
  
          return True
docs: Checks if given URL has valid domain name (ignores subdomains)
  
          :param str url: complete URL that we want to check
          :param str tld: TLD that should be found at the end of URL (hostname)
          :return: True if URL is valid, False otherwise
          :rtype: bool
  
          >>> extractor = URLExtract()
          >>> extractor._is_domain_valid("janlipovsky.cz", ".cz")
          True
  
          >>> extractor._is_domain_valid("https://janlipovsky.cz", ".cz")
          True
  
          >>> extractor._is_domain_valid("invalid.cz.", ".cz")
          False
  
          >>> extractor._is_domain_valid("invalid.cz,", ".cz")
          False
  
          >>> extractor._is_domain_valid("in.v_alid.cz", ".cz")
          False
  
          >>> extractor._is_domain_valid("-is.valid.cz", ".cz")
          True
  
          >>> extractor._is_domain_valid("not.valid-.cz", ".cz")
          False
  
          >>> extractor._is_domain_valid("http://blog/media/path.io.jpg", ".cz")
          False