How to use the tld.get_tld function in tld

To help you get started, we’ve selected a few tld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecstatic-nobel / Analyst-Arsenal / commons.py View on Github external
def score_domain(config, domain, args):
    """ """
    score = 0

    for t in config["tlds"]:
        if domain.endswith(t):
            score += 20

    try:
        res = get_tld(domain, as_object=True, fail_silently=True, fix_protocol=True)

        if res is not None:
            domain = '.'.join([res.subdomain, res.domain])
    except Exception as err:
        message_failed(args, err, domain)
        pass

    score += int(round(entropy.shannon_entropy(domain)*50))

    domain          = unconfuse(domain)
    words_in_domain = re.split(r"\W+", domain)

    if words_in_domain[0] in ["com", "net", "org"]:
        score += 10

    for word in config["keywords"]:
github stratosphereips / whois-similarity-distance / whois_similarity_distance / util / whois_obj.py View on Github external
def __get_top_level_domain__(self):
        try:
            if is_ip(self.domain) or not self.domain or self.domain == '':
                return None
            d = get_tld('http://www.'+self.domain)
            if d.find('www.') >= 0:
                return d.split('www.')[1]
            else:
                return d
        except:
            return None
github apache / incubator-spot / spot-oa / oa / dns / dns_oa.py View on Github external
def _add_tld_column(self):
        qry_name_col = self._conf['dns_results_fields']['dns_qry_name'] 
        self._dns_scores = [conn + [ get_tld("http://" + str(conn[qry_name_col]), fail_silently=True) if "http://" not in str(conn[qry_name_col]) else get_tld(str(conn[qry_name_col]), fail_silently=True)] for conn in self._dns_scores ] 
github VainlyStrain / Vaile / modules / VlnAnalysis / Severe / fileo / subdom.py View on Github external
sublist.append(a)

    except IOError:
        print(R+' [-] Wordlist not found!')

    global found
    if 'http://' in web:
        web = web.replace('http://','')
    elif 'https://' in web:
        web = web.replace('https://','')
    else:
        pass

    web = 'http://' + web

    tld0 = get_tld(web, as_object=True)

    if len(sublist) > 0:
        for m in sublist:
            furl = str(m) + '.' + str(tld0)
            flist.append(furl)

    if flist:
        time.sleep(0.5)
        print(R+'\n      B R U T E F O R C E R')
        print(R+'     =======================\n')
        print(GR+' [*] Bruteforcing for possible subdomains...')
        for url in flist:
            if 'http://' in url:
                url = url.replace('http://','')
            elif 'https://' in url:
                url = url.replace('https://','')
github osroom / osroom / apps / utils / format / url_format.py View on Github external
def get_domain(url):
    """
    获取url中的全域名
    :param url:
    :return:
    """
    try:
        res = get_tld(url, as_object=True)
    except:
        return False
    return "{}.{}".format(res.subdomain, res.tld)
github penafieljlm / inquisitor / inquisitor / assets / host.py View on Github external
def canonicalize(host):
    if not host:
        raise HostValidateException('Hosts cannot be None')
    if not isinstance(host, str) and not isinstance(host, unicode):
        raise HostValidateException('Hosts must be strings')
    host = host.strip().lower()
    try:
        tld.get_tld('http://{}'.format(host))
    except tld.exceptions.TldDomainNotFound:
        raise HostValidateException('Invalid tld for host {}'.format(host))
    return host
github rohit-dua / BUB / digi-lib / usp.py View on Github external
def extract_base_domain(url):
    """Extract and return the base domain name from the url."""
    tld = get_tld(url)
    u = re.search('.+%s' %tld, url)
    if u:
        return u.group()
    else:
        return ""
github kappataumu / letsencrypt-cloudflare-hook / hook.py View on Github external
def _get_zone_id(domain):
    tld = get_tld('http://' + domain)
    url = "https://api.cloudflare.com/client/v4/zones?name={0}".format(tld)
    r = requests.get(url, headers=CF_HEADERS)
    r.raise_for_status()
    return r.json()['result'][0]['id']
github nasa-jpl-memex / memex-explorer / source / apps / crawl_space / viz / domain.py View on Github external
def extract_tld(self, url):
        try:
            return get_tld(url)
        except:
            traceback.print_exc()
            print "\n\nInvalid url: %s" % url
            return url
github audax / pypo / readme / models.py View on Github external
def domain(self):
        """
        Domain of the url
        """
        return get_tld(self.url, fail_silently=True)

tld

Extract the top-level domain (TLD) from the URL given.

MPL-1.1 OR GPL-2.0-only OR LG…
Latest version published 2 years ago

Package Health Score

78 / 100
Full package analysis