https://github.com/ninoseki/whois-parser
Yet another whois parser for Python
https://github.com/ninoseki/whois-parser
whois
Last synced: 6 months ago
JSON representation
Yet another whois parser for Python
- Host: GitHub
- URL: https://github.com/ninoseki/whois-parser
- Owner: ninoseki
- License: mit
- Created: 2021-05-29T22:39:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T08:54:57.000Z (almost 2 years ago)
- Last Synced: 2024-03-15T14:20:44.733Z (over 1 year ago)
- Topics: whois
- Language: Python
- Homepage:
- Size: 133 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# whois-parser
[](https://badge.fury.io/py/whois-parser)
[](https://github.com/ninoseki/whois-parser/actions/workflows/test.yml)
[](https://coveralls.io/github/ninoseki/whois-parser?branch=main)Yet another whois parser for Python. π
- Parse a whois record by using [PyParsing](https://github.com/pyparsing/pyparsing/) not Regex.
- Return a parsed record as [dataclass](https://docs.python.org/3/library/dataclasses.html) not dict.## Installation
```bash
pip install whois-parser
```## Usage
```python
import sh
from whois_parser import WhoisParser# get whois record
hostname = "google.co.jp"
whois = sh.Command("whois")
raw_text = whois(hostname)# parse whois record
parser = WhoisParser()
record = parser.parse(raw_text, hostname=hostname)
print(record)
# => WhoisRecord(raw_text="...", registrant=Registrant(organization='γ°γΌγ°γ«εεδΌη€Ύ', email=None, name=None, telephone=None), admin=Admin(organization=None, email=None, name=None, telephone=None), tech=Tech(organization=None, email=None, name=None, telephone=None), abuse=Abuse(email=None, telephone=None), statuses=['Connected (2022/03/31)'], name_servers=['ns1.google.com', 'ns2.google.com', 'ns3.google.com', 'ns4.google.com'], domain='google.co.jp', registrar=None, expires_at=None, registered_at=datetime.datetime(2001, 3, 22, 0, 0), updated_at=datetime.datetime(2021, 4, 1, 1, 5, 22, tzinfo=))
```## Customize / Contribution
Whois's responses will follow a semi-free text format. Thus, unfortunately, this library does not support all the formats in the wild.
You can create customized parsers to suit your needs. References are placed in `whois-parser/parsers/`.
Any contribution is welcome.