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.
- Works with Python 2 & 3
Example
=======
.. sourcecode:: bash
>>> 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:
.. sourcecode:: bash
$ pip install whois-pypi
Or checkout latest version from repository:
.. sourcecode:: bash
$ git clone https://github.com/Paradoxxs/pywhois
Note that then you will need to manually install the futures module, which allows supporting both Python 2 & 3:
.. sourcecode:: bash
$ pip install futures
Run test cases for python 2 & 3:
.. sourcecode:: bash
$ python -m unittest discover test
.............
----------------------------------------------------------------------
Ran 13 tests in 0.812s
OK
$ python3 -m unittest discover test
.............
----------------------------------------------------------------------
Ran 13 tests in 1.431s
OK
SOCKS Proxy support requirements:
.. sourcecode:: bash
$ pip install PySocks
............
---------------------------------------------------------------------
$ export SOCKS=socksproxy.someplace.com:8080
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:
.. sourcecode:: 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/Paradoxxs/pywhois",
"name": "whois-pypi",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "whois,python",
"author": "Paradoxxs",
"author_email": "pypi@adamtilmar.com",
"download_url": "https://files.pythonhosted.org/packages/a6/e5/37a4d05438481940c02bf97dc25f37ab4cd6ec32e9e24bfd4bf8a12c35d1/whois-pypi-0.2.tar.gz",
"platform": null,
"description": "Goal\r\n====\r\n\r\n- Create a simple importable Python module which will produce parsed\r\n WHOIS data for a given domain.\r\n- Able to extract data for all the popular TLDs (com, org, net, ...)\r\n- Query a WHOIS server directly instead of going through an\r\n intermediate web service like many others do.\r\n- Works with Python 2 & 3\r\n\r\n\r\n\r\nExample\r\n=======\r\n\r\n.. sourcecode:: bash\r\n\r\n >>> import whois\r\n >>> w = whois.whois('example.com')\r\n >>> w.expiration_date # dates converted to datetime object\r\n datetime.datetime(2022, 8, 13, 4, 0)\r\n >>> w.text # the content downloaded from whois server\r\n u'\\nDomain Name: EXAMPLE.COM\r\n Registry Domain ID: 2336799_DOMAIN_COM-VRSN\r\n ...'\r\n\r\n >>> print w # print values of all found attributes \r\n {\r\n \"creation_date\": \"1995-08-14 04:00:00\",\r\n \"expiration_date\": \"2022-08-13 04:00:00\",\r\n \"updated_date\": \"2021-08-14 07:01:44\",\r\n \"domain_name\": \"EXAMPLE.COM\",\r\n \"name_servers\": [\r\n \"A.IANA-SERVERS.NET\",\r\n \"B.IANA-SERVERS.NET\"\r\n ],\r\n ...\r\n\r\n\r\nInstall\r\n=======\r\n\r\nInstall from pypi:\r\n\r\n.. sourcecode:: bash\r\n\r\n $ pip install whois-pypi\r\n\r\nOr checkout latest version from repository:\r\n\r\n.. sourcecode:: bash\r\n\r\n $ git clone https://github.com/Paradoxxs/pywhois\r\n\r\nNote that then you will need to manually install the futures module, which allows supporting both Python 2 & 3:\r\n\r\n\r\n.. sourcecode:: bash\r\n\r\n $ pip install futures\r\n\r\nRun test cases for python 2 & 3:\r\n\r\n.. sourcecode:: bash\r\n\r\n $ python -m unittest discover test\r\n .............\r\n ----------------------------------------------------------------------\r\n Ran 13 tests in 0.812s\r\n \r\n OK\r\n \r\n $ python3 -m unittest discover test\r\n .............\r\n ----------------------------------------------------------------------\r\n Ran 13 tests in 1.431s\r\n \r\n OK\r\n\r\nSOCKS Proxy support requirements:\r\n\r\n.. sourcecode:: bash\r\n\r\n $ pip install PySocks\r\n ............\r\n ---------------------------------------------------------------------\r\n $ export SOCKS=socksproxy.someplace.com:8080\r\n\r\n\r\nProblems?\r\n=========\r\n\r\nPull requests are welcome! \r\n\r\nThanks to the many who have sent patches for additional TLDs. If you want to add or fix a TLD it's quite straightforward. \r\nSee example domains in `whois/parser.py <https://github.com/richardpenman/whois/blob/master/whois/parser.py>`_\r\n\r\nBasically each TLD has a similar format to the following:\r\n\r\n.. sourcecode:: python\r\n\r\n class WhoisOrg(WhoisEntry):\r\n \"\"\"Whois parser for .org domains\r\n \"\"\"\r\n regex = {\r\n 'domain_name': 'Domain Name: *(.+)',\r\n 'registrar': 'Registrar: *(.+)',\r\n 'whois_server': 'Whois Server: *(.+)',\r\n ...\r\n }\r\n\r\n def __init__(self, domain, text):\r\n if text.strip() == 'NOT FOUND':\r\n raise PywhoisError(text)\r\n else:\r\n WhoisEntry.__init__(self, domain, text)\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Whois querying and parsing of domain registration information.",
"version": "0.2",
"project_urls": {
"Homepage": "https://github.com/Paradoxxs/pywhois"
},
"split_keywords": [
"whois",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "48b64b79c78c9a2a869bb7bfb0590628127d0285cedb3fc181b0c4cf26d5982d",
"md5": "1fb27f8d6f4000c7ac0e6be60b709016",
"sha256": "e58c3fa6e4d2da66ea24a702cd5c60195aa1bd0086afa0a63218a4afa2348085"
},
"downloads": -1,
"filename": "whois_pypi-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1fb27f8d6f4000c7ac0e6be60b709016",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 107079,
"upload_time": "2024-02-07T12:14:57",
"upload_time_iso_8601": "2024-02-07T12:14:57.914039Z",
"url": "https://files.pythonhosted.org/packages/48/b6/4b79c78c9a2a869bb7bfb0590628127d0285cedb3fc181b0c4cf26d5982d/whois_pypi-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a6e537a4d05438481940c02bf97dc25f37ab4cd6ec32e9e24bfd4bf8a12c35d1",
"md5": "8e12b33a8b35a8d59a4c92ddc8c55284",
"sha256": "6ba8a1dd4ba1eda0c8d063773df1bf250a954b3a0544f0b72068cefe2c12ac04"
},
"downloads": -1,
"filename": "whois-pypi-0.2.tar.gz",
"has_sig": false,
"md5_digest": "8e12b33a8b35a8d59a4c92ddc8c55284",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 115211,
"upload_time": "2024-02-07T12:14:59",
"upload_time_iso_8601": "2024-02-07T12:14:59.846577Z",
"url": "https://files.pythonhosted.org/packages/a6/e5/37a4d05438481940c02bf97dc25f37ab4cd6ec32e9e24bfd4bf8a12c35d1/whois-pypi-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-07 12:14:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Paradoxxs",
"github_project": "pywhois",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "whois-pypi"
}