Skip to main content

Detect the registered domains for given hostnames based on Mozillas effective TLD listing

Project description

pyregdom - Python library for Mozilla Public Suffix list

A Python version of usrflo’s regdom libs to detect the registered domain for a given domain name, based on Mozillas effective TLD listing.

Installation

From source code:

$ sudo python setup.py install

Using pip:

$ pip install pyregdom

Usage

>>> import regdom

>>> regdom.get_registered_domain("mail.google.com")
'google.com'

>>> regdom.get_registered_domain("foobar.github.io")
'foobar.github.io'

>>> regdom.get_registered_domain("a.b.c.city.kawasaki.jp")
'city.kawasaki.jp'

>>> regdom.get_registered_domain("invalid_domain_name.com") # return None

>>> regdom.get_registered_domain("not-recognized-tld.smile")
'not-recognized-tld.smile'

>>> regdom.get_registered_domain("not-recognized-tld.smile", fallback=False) # return None

Update the list

Simply run the script generate_effective_tlds.py under scripts directory, it will download and parse the latest Mozilla Public Suffix

$ scripts/generate_effective_tlds.py

Then re-install the module from source.

You can also use your own list file:

$ scripts/generate_effective_tlds.py your_own_list_file.dat

The script doesn’t check for the format of the file so make sure you have it in the same format defined at Mozilla Public List.

Author of this module will also update pyregdom on pypi every month if there are changes in the list.

Source code

Source code is hosted at Github, you can get a local copy of the development repository with:

$ git clone https://github.com/huyphan/pyregdom

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyregdom-0.4-2.tar.gz (31.8 kB view details)

Uploaded Source

File details

Details for the file pyregdom-0.4-2.tar.gz.

File metadata

  • Download URL: pyregdom-0.4-2.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyregdom-0.4-2.tar.gz
Algorithm Hash digest
SHA256 cecdfab0fea4d590a6a3e23f1b6c7afd9f3acc0e0f8f638289b2105c3cc1adbf
MD5 a1c90655e83f5e29ceb0da2fd8a8c2d1
BLAKE2b-256 6c22083f7f629d104f742f086ae5889a4fd48d4156c17f6167000b222e60a86a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page