Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list of 2ld.1ld (2nd level domain.1st(top)level domain) names?

I am looking for a list of (doesnt matter if its not all, just needs to be big as its for generating dummy data)

Im looking for a list like

.net.nz
.co.nz
.edu.nz
.govt.nz
.com.au
.govt.au
.com
.net

any ideas where I can locate a list?

like image 399
Hailwood Avatar asked Mar 10 '11 07:03

Hailwood


People also ask

What are second-level domain names?

A Second Level Domain (SLD) is the part of the domain name that is located right before a Top Level Domain (TLD). For example, in mozilla.org the SLD is mozilla and the TLD is org . A domain name is not limited to a TLD and an SLD.


2 Answers

There are answers here. Most of them are relating to the use of http://publicsuffix.org/, and even some implementations to use it were given in some languages, like Ruby.

like image 180
Rafael Avatar answered Oct 28 '22 06:10

Rafael


To get all the ICANN domains, this python code should work for you:

import requests
url = 'https://publicsuffix.org/list/public_suffix_list.dat'
page = requests.get(url)

icann_domains = []
for line in page.text.splitlines():
    if 'END ICANN DOMAINS' in line:
        break
    elif line.startswith('//'):
        continue
    else:
        domain = line.strip()
        if domain:
            icann_domains.append(domain)

print(len(icann_domains)) # 7334 as of Nov 2018

Remove the break statement to get private domains as well.

Be careful as you will get some domains like this: *.kh (e.g. http://www.mptc.gov.kh/dns_registration.htm). The * is a wildcard.

like image 2
AlexG Avatar answered Oct 28 '22 06:10

AlexG