Skip to main content

Whois querying and parsing of domain registration information.

Project description

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 [email protected]: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)

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

python_whois-0.9.6.tar.gz (125.1 kB view details)

Uploaded Source

Built Distribution

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

python_whois-0.9.6-py3-none-any.whl (117.0 kB view details)

Uploaded Python 3

File details

Details for the file python_whois-0.9.6.tar.gz.

File metadata

  • Download URL: python_whois-0.9.6.tar.gz
  • Upload date:
  • Size: 125.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for python_whois-0.9.6.tar.gz
Algorithm Hash digest
SHA256 2e6de7b6d70e305a85f4859cd17781ee3f0da3a02a8e94f23cb4cdcd2e400bfa
MD5 871f12f557c9aaf6ce7b994064e7aca5
BLAKE2b-256 f10c537914eca91ee5ff281309a5ca71da23c0c975cd6658668a44d3fdcf1cc4

See more details on using hashes here.

File details

Details for the file python_whois-0.9.6-py3-none-any.whl.

File metadata

  • Download URL: python_whois-0.9.6-py3-none-any.whl
  • Upload date:
  • Size: 117.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for python_whois-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 153261941a4d238b1278a4ca9b5b5e0590ed3b4d0c534ba111c4434d5d339410
MD5 979ce86c1489482d9f8d9bb2e7fb20ba
BLAKE2b-256 4653d0ceb3ae30da8e8ec2d9af11050178f3b4114d5aa6a7f7074199db3c806f

See more details on using hashes here.

Supported by

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