Skip to main content

Get a public suffix for a domain name using an up-to-date Public Suffix List. Forked from and using the same API as the publicsuffix package.

Project description

This module allows you to get the public suffix of a domain name using the Public Suffix List from http://publicsuffix.org

A public suffix is a domain suffix under which you can register domain names. Some examples of public suffixes are .com, .co.uk and pvt.k12.wy.us. Accurately knowing the public suffix of a domain is useful when handling web browser cookies, highlighting the most important part of a domain name in a user interface or sorting URLs by web site.

This Python module includes with a copy of the Public Suffix List so that it is usable out of the box. Newer version try to provide reasonably fresh copies of this list.

The code is a fork of the publicsuffix package and uses the same module name and API.

The code is MIT-licensed and the publicsuffix data list is MPL-2.0-licensed.

Usage

Install with:

pip install publicsuffix2

The module exports a single class that parses the Public Suffix List and allows queries for individual domain names:

>>> from publicsuffix import PublicSuffixList
>>> psl= PublicSuffixList()
>>> psl.get_public_suffix('www.example.com')
u'example.com'
>>> psl.get_public_suffix('www.example.co.uk')
u'example.co.uk'
>>> psl.get_public_suffix('www.super.example.co.uk')
u'example.co.uk'

Note that the host part of an URL can contain strings that are not plain DNS domain names (IP addresses, Punycode-encoded names, name in combination with a port number or a username, etc.). It is up to the caller to ensure only domain names are passed to the get_public_suffix() method.

Source

Get a local copy of the development repository. The development takes place in the develop branch. Stable releases are tagged in the master branch:

git clone https://github.com/pombredanne/python-publicsuffix2.git

2015-06-04 publicsuffix2 2.0.0

  • Forked publicsuffix, but kept the same API

  • Updated publicsuffix.file to the latest version from Mozilla.

  • Changed packaging to have the suffix list be package data and be wheel friendly.

  • Use spaces indentation, not tabs

2014-01-14 publicsuffix 1.0.5

  • Correctly handle fully qualified domain names (thanks to Matthäus Wander).

  • Updated publicsuffix.txt to the latest version from Mozilla.

2013-01-02 publicsuffix 1.0.4

  • Added missing change log.

2013-01-02 publicsuffix 1.0.3

  • Updated publicsuffix.txt to the latest version from Mozilla.

  • Added trove classifiers.

  • Minor update of the README.

2011-10-10 publicsuffix 1.0.2

  • Compatibility with Python 3.x (thanks to Joern Koerner) and Python 2.5

2011-09-22 publicsuffix 1.0.1

  • Fixed installation issue under virtualenv (thanks to Mark McClain)

2011-07-29 publicsuffix 1.0.0

  • First release

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

publicsuffix2-2.0.1.tar.gz (66.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

publicsuffix2-2.0.1-py2.py3-none-any.whl (66.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file publicsuffix2-2.0.1.tar.gz.

File metadata

  • Download URL: publicsuffix2-2.0.1.tar.gz
  • Upload date:
  • Size: 66.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for publicsuffix2-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1f954d1de6b872dba4136a7633f17be66dafe48bdda777679f24cd5e91bc1174
MD5 2e66a7f9fb5f4c8e5a4993c223bcd5f9
BLAKE2b-256 24d6eb424bc59722bbbfb710ccf7c8bcea8c9ea2f0549761b610cc5aebbb6ec2

See more details on using hashes here.

File details

Details for the file publicsuffix2-2.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for publicsuffix2-2.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 03354bc5aa9d6af3b86904de0d3f891cf7247cb271d394e0690ddb3141a781b7
MD5 bb38b3913b53b601417c8aa3325eb5c6
BLAKE2b-256 b3de7011fc7d06afc2319813df5063f196c4ef518d4c365179ed38d71ea236e1

See more details on using hashes here.

Supported by

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