Skip to main content

Goal

  • Create a simple importable Python module which will produce parsed WHOIS data for a given domain.
  • Able to extract data for all the popular TLDs (com, org, net, ...)
  • Query a WHOIS server directly instead of going through an intermediate web service like many others do.

Example

>>> import whois
>>> w = whois.whois('example.com')
>>> w.expiration_date  # dates converted to datetime object
datetime.datetime(2022, 8, 13, 4, 0, tzinfo=tzoffset('UTC', 0))
>>> w.text  # the content downloaded from whois server
u'\nDomain Name: EXAMPLE.COM
Registry Domain ID: 2336799_DOMAIN_COM-VRSN
...'

>>> print(w)  # print values of all found attributes
{
  "creation_date": "1995-08-14 04:00:00+00:00",
  "expiration_date": "2022-08-13 04:00:00+00:00",
  "updated_date": "2021-08-14 07:01:44+00:00",
  "domain_name": "EXAMPLE.COM",
  "name_servers": [
      "A.IANA-SERVERS.NET",
      "B.IANA-SERVERS.NET"
  ],
  ...

Install

Install from pypi:

pip install python-whois

Or checkout latest version from repository:

git clone git@github.com:richardpenman/whois.git
pip install -r requirements.txt

Run test cases:

python -m pytest

Using a proxy.

Set your environment SOCKS variable

export SOCKS="username:password@proxy_address:port"

Problems?

Pull requests are welcome!

Thanks to the many who have sent patches for additional TLDs. If you want to add or fix a TLD it's quite straightforward. See example domains in whois/parser.py

Basically each TLD has a similar format to the following:

class WhoisOrg(WhoisEntry):
  """Whois parser for .org domains
  """
  regex = {
    'domain_name':      'Domain Name: *(.+)',
    'registrar':        'Registrar: *(.+)',
    'whois_server':     'Whois Server: *(.+)',
    ...
  }

  def __init__(self, domain, text):
    if text.strip() == 'NOT FOUND':
      raise WhoisDomainNotFoundError(text)
    else:
      WhoisEntry.__init__(self, domain, text, self.regex)

Release files for python-whois 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-whois 0.9.6
File Size Uploaded
python_whois-0.9.6.tar.gz 125.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-whois 0.9.6
File Interpreter ABI Platform
python_whois-0.9.6-py3-none-any.whl Python 3 none any Details

Total release size: 242.1 kB

Release files / python_whois-0.9.6.tar.gz

Download URL python_whois-0.9.6.tar.gz
Size 125.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2e6de7b6d70e305a85f4859cd17781ee3f0da3a02a8e94f23cb4cdcd2e400bfa
BLAKE2b-256 checksum
How to use checksums
f10c537914eca91ee5ff281309a5ca71da23c0c975cd6658668a44d3fdcf1cc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / python_whois-0.9.6-py3-none-any.whl

Download URL python_whois-0.9.6-py3-none-any.whl
Size 117.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
153261941a4d238b1278a4ca9b5b5e0590ed3b4d0c534ba111c4434d5d339410
BLAKE2b-256 checksum
How to use checksums
4653d0ceb3ae30da8e8ec2d9af11050178f3b4114d5aa6a7f7074199db3c806f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.9

1 release file

0.6.8

1 release file

0.6.7

1 release file

0.6.5

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5

1 release file

0.4

1 release file

0.3.1

1 release file

0.3

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page