Registered Domain

back to: [tools] [homepage]

Introduction

A small python script that can find (and/or extract) the "registered domain" (or effective TLD, or public suffix) in DNS domain names. It utilizes Mozilla's Public Suffix List

Some examples:

DNS name Registered Domain effective TLD
foo.bar.com bar com
foo.bar.co.uk bar co.uk

The public suffix list is a text file. Ideally however we would want to have a python script (or module) that has the list "embedded" in its code, so that we don't have to read and parse the suffix list file every time the script is run. On the other hand we want to be able to update the list if necessary without too much pain.

We solve this by writing a generator script (gen_registered_domain.py) that can generate a python script (module) that has the logic implemented. One can to this by feeding an effective_tld_names.dat to the script on stdin. The generated python files is written to stdout:
./gen_registered_domain.py < effective_tld_names.dat > registered_domain.py
I have tested it and compared the output with regdom-libs. My scripts passed the test.

Download


back to: [tools] [homepage]
Contact: Gregor Maier: gregor _AT_ majordomus.org