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)
>>> 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",
"expiration_date": "2022-08-13 04:00:00",
"updated_date": "2021-08-14 07:01:44",
"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
```
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 PywhoisError(text)
else:
WhoisEntry.__init__(self, domain, text)
```
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/f5/5b/5c0c705d14945954b23b69042c1597971da3cd6dc3ed23b96449be91d665/python_whois-0.9.5.tar.gz",
"platform": null,
"description": "Goal\n====\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\nExample\n=======\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)\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\",\n \"expiration_date\": \"2022-08-13 04:00:00\",\n \"updated_date\": \"2021-08-14 07:01:44\",\n \"domain_name\": \"EXAMPLE.COM\",\n \"name_servers\": [\n \"A.IANA-SERVERS.NET\",\n \"B.IANA-SERVERS.NET\"\n ],\n ...\n```\n\nInstall\n=======\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\nProblems?\n=========\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 PywhoisError(text)\n else:\n WhoisEntry.__init__(self, domain, text)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Whois querying and parsing of domain registration information.",
"version": "0.9.5",
"project_urls": {
"Homepage": "https://github.com/richardpenman/whois"
},
"split_keywords": [
"whois",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "be7b6a5ee6895b1bffb630da9c1a472ced41f537f2700f76e69bd62e01776e1b",
"md5": "b5aeffdbada07277e139e9a068a270c4",
"sha256": "d435cf8012659745ce3b4e7c15428df9405648696727812d9eaacc36782d14e3"
},
"downloads": -1,
"filename": "python_whois-0.9.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b5aeffdbada07277e139e9a068a270c4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 104155,
"upload_time": "2024-11-17T08:26:20",
"upload_time_iso_8601": "2024-11-17T08:26:20.858740Z",
"url": "https://files.pythonhosted.org/packages/be/7b/6a5ee6895b1bffb630da9c1a472ced41f537f2700f76e69bd62e01776e1b/python_whois-0.9.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f55b5c0c705d14945954b23b69042c1597971da3cd6dc3ed23b96449be91d665",
"md5": "afb644cb9029b452916bca48a539387d",
"sha256": "18968c21484752fcc4b9a5f0af477ef6b8dc2e8bb7f1bd5c33831499c0dd41ca"
},
"downloads": -1,
"filename": "python_whois-0.9.5.tar.gz",
"has_sig": false,
"md5_digest": "afb644cb9029b452916bca48a539387d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 111201,
"upload_time": "2024-11-17T08:26:22",
"upload_time_iso_8601": "2024-11-17T08:26:22.862773Z",
"url": "https://files.pythonhosted.org/packages/f5/5b/5c0c705d14945954b23b69042c1597971da3cd6dc3ed23b96449be91d665/python_whois-0.9.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-17 08:26:22",
"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"
}