# 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
```python
>>> 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:
```bash
pip install python-whois
```
Or checkout latest version from repository:
```bash
git clone git@github.com:richardpenman/whois.git
pip install -r requirements.txt
```
Run test cases:
```bash
python -m pytest
```
# Using a proxy.
Set your environment SOCKS variable
```bash
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](https://github.com/richardpenman/whois/blob/master/whois/parser.py)
Basically each TLD has a similar format to the following:
```python
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)
```
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": "https://github.com/richardpenman/whois",
    "name": "python-whois",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "whois, python",
    "author": "Richard Penman",
    "author_email": "richard.penman@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f1/0c/537914eca91ee5ff281309a5ca71da23c0c975cd6658668a44d3fdcf1cc4/python_whois-0.9.6.tar.gz",
    "platform": null,
    "description": "# Goal\n\n- Create a simple importable Python module which will produce parsed\n  WHOIS data for a given domain.\n- Able to extract data for all the popular TLDs (com, org, net, ...)\n- Query a WHOIS server directly instead of going through an\n  intermediate web service like many others do.\n\n# Example\n\n```python\n>>> import whois\n>>> w = whois.whois('example.com')\n>>> w.expiration_date  # dates converted to datetime object\ndatetime.datetime(2022, 8, 13, 4, 0, tzinfo=tzoffset('UTC', 0))\n>>> w.text  # the content downloaded from whois server\nu'\\nDomain Name: EXAMPLE.COM\nRegistry Domain ID: 2336799_DOMAIN_COM-VRSN\n...'\n\n>>> print(w)  # print values of all found attributes\n{\n  \"creation_date\": \"1995-08-14 04:00:00+00:00\",\n  \"expiration_date\": \"2022-08-13 04:00:00+00:00\",\n  \"updated_date\": \"2021-08-14 07:01:44+00:00\",\n  \"domain_name\": \"EXAMPLE.COM\",\n  \"name_servers\": [\n      \"A.IANA-SERVERS.NET\",\n      \"B.IANA-SERVERS.NET\"\n  ],\n  ...\n```\n\n# Install\n\nInstall from pypi:\n\n```bash\npip install python-whois\n```\n\nOr checkout latest version from repository:\n\n```bash\ngit clone git@github.com:richardpenman/whois.git\npip install -r requirements.txt\n```\n\nRun test cases:\n\n```bash\npython -m pytest\n```\n\n# Using a proxy.\n\nSet your environment SOCKS variable\n```bash\nexport SOCKS=\"username:password@proxy_address:port\"\n```\n\n# Problems?\n\nPull requests are welcome!\n\nThanks to the many who have sent patches for additional TLDs. If you want to add or fix a TLD it's quite straightforward.\nSee example domains in [whois/parser.py](https://github.com/richardpenman/whois/blob/master/whois/parser.py)\n\nBasically each TLD has a similar format to the following:\n\n```python\nclass WhoisOrg(WhoisEntry):\n  \"\"\"Whois parser for .org domains\n  \"\"\"\n  regex = {\n    'domain_name':      'Domain Name: *(.+)',\n    'registrar':        'Registrar: *(.+)',\n    'whois_server':     'Whois Server: *(.+)',\n    ...\n  }\n\n  def __init__(self, domain, text):\n    if text.strip() == 'NOT FOUND':\n      raise WhoisDomainNotFoundError(text)\n    else:\n      WhoisEntry.__init__(self, domain, text, self.regex)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Whois querying and parsing of domain registration information.",
    "version": "0.9.6",
    "project_urls": {
        "Homepage": "https://github.com/richardpenman/whois"
    },
    "split_keywords": [
        "whois",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4653d0ceb3ae30da8e8ec2d9af11050178f3b4114d5aa6a7f7074199db3c806f",
                "md5": "979ce86c1489482d9f8d9bb2e7fb20ba",
                "sha256": "153261941a4d238b1278a4ca9b5b5e0590ed3b4d0c534ba111c4434d5d339410"
            },
            "downloads": -1,
            "filename": "python_whois-0.9.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "979ce86c1489482d9f8d9bb2e7fb20ba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 116976,
            "upload_time": "2025-10-07T04:36:12",
            "upload_time_iso_8601": "2025-10-07T04:36:12.328722Z",
            "url": "https://files.pythonhosted.org/packages/46/53/d0ceb3ae30da8e8ec2d9af11050178f3b4114d5aa6a7f7074199db3c806f/python_whois-0.9.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f10c537914eca91ee5ff281309a5ca71da23c0c975cd6658668a44d3fdcf1cc4",
                "md5": "871f12f557c9aaf6ce7b994064e7aca5",
                "sha256": "2e6de7b6d70e305a85f4859cd17781ee3f0da3a02a8e94f23cb4cdcd2e400bfa"
            },
            "downloads": -1,
            "filename": "python_whois-0.9.6.tar.gz",
            "has_sig": false,
            "md5_digest": "871f12f557c9aaf6ce7b994064e7aca5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 125107,
            "upload_time": "2025-10-07T04:36:14",
            "upload_time_iso_8601": "2025-10-07T04:36:14.913512Z",
            "url": "https://files.pythonhosted.org/packages/f1/0c/537914eca91ee5ff281309a5ca71da23c0c975cd6658668a44d3fdcf1cc4/python_whois-0.9.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-07 04:36:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "richardpenman",
    "github_project": "whois",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.9.0.post0"
                ]
            ]
        }
    ],
    "lcname": "python-whois"
}