Skip to main content

A simple and easy to use Python package that lets you query whois/RDAP information of a domain/IP.

Project description

whois21

version stars forks repo size CodeFactor

WHOIS21 is a simple and easy to use python package that lets you easily query whois information of a domain.

Features

WHOIS

  • Query whois information of a TLD from various whois servers and parse the results.
  • Get the Registration Information of a domain from different RDAP servers and parse the results.
  • Get IP information from ip-api.com.
  • Any idea? Feel free to open an issue or submit a pull request.

issues contributors

Installation

Well, this is a python package so the first thing you need is python.

If you don't have python installed, please visit Python.org and install the latest version of python based on your OS.

Then you can install whois21 using pip module:

# Use this command to get the latest version from pypi.org and install it automatically
python -m pip install whois21 -U

# OR
# Download the release file from GitHub: https://github.com/MPCodeWriter21/whois21/releases
# And install it using this command
pip install whois21-x.x.x.tar.gz

Or you can clone the repository and run:

python -m build .

Dependencies

  • requests: Used for:
    • Downloading list of whois and RDAP servers.
    • Downloading RDAP information.
  • importlib_resources: Used for:
    • Getting the path to the whois21 package installation directory(for saving server lists).
  • chardet: Used for:
    • Detecting the encoding of the whois response.
  • log21: Used for:
    • Colorized Logging.
    • Printing collected data in pprint or tree format.
  • os (A core python module): Used for:
    • Working with files and directories.
  • socket (A core python module): Used for:
    • Establishing TCP connection to the whois server.
  • json (A core python module): Used for:
    • Parsing JSON data from RDAP servers.
    • Parsing RDAP server list.
    • Saving collected whois or/and RDAP data to a file.
    • Loading some package data from a file.
  • datetime (A core python module): Used for:
    • Converting Creation/Updated/Expiration date to a usable python datetime object.
  • ipaddress (A core python module): Used for:
    • Validating IPv4 and IPv6 addresses.
  • typing (A core python module): Used for:
    • Type checking.
    • Type hinting.
  • re (A core python module): Used for:
    • Matching date-time strings with regular expressions.

Changes

1.3.0

  • Added the option to specify the encoding to use for encoding and decoding the data in in WHOIS class.
  • Added the option to customize the behavior of the WHOIS class when it encounters an error while encoding or decoding data.
  • Added the feature to automatically detect the encoding of whois response to solve decoding issues, such as the one mentioned in issue #2. This is done with the help of chardet package.

Usage Examples:

CLI Examples

  • Example 1: Query whois information of google.com
# -v : verbose mode
whois21 -v results google.com
  • Example 2: Query whois information of 3 domains and save the results to a directory
# -R : saves the results as raw text
# -np: avoids printing the results to the screen
# -o results: saves the results to `./results` directory 
whois21 -R -np -o results google.com facebook.com pinterest.com
  • Example 3: Query whois information of 3 IPs and save the results to a directory
# Options explained in the examples above
whois21 -R -np -v -o results 1.1.1.1 157.240.20.174 64.91.226.82
  • Example 4: Query RDAP information of domains and IPs and save the results to a file
# -r: Gets the RDAP information of the queried domains and IPs
whois21 -np -o results -o results -r microsoft.com python.org 140.82.121.3 185.147.178.13

Python Code Examples

  • Example 1: Query whois information of GitHub.com using WHOIS class.
# First step is to import the package
import whois21

query = 'github.com'

# Second step is to create an instance of the WHOIS class
whois = whois21.WHOIS(query)

# Third step is to check if the operation was successful
if not whois.success:
    print(whois.error)
    exit()

# And basically you are done!
# Now you can print the results
import log21  # I use log21 to print the results in a cool way 8D

# Print the results in a nice way
# PPrint the dictionary
log21.pprint(whois.whois_data)
# Tree-Print the dictionary
log21.tree_print(whois.whois_data)

# Or you can print the results in as raw text
print(whois.raw.decode('utf-8'))

# Or you can access each part of the results individually
print(f'Creation date   : {whois.creation_date}')
print(f'Expiration date : {whois.expires_date}')
print(f'Updated date    : {whois.updated_date}')

About

Author: CodeWriter21 (Mehrad Pooryoussof)

GitHub: MPCodeWriter21

Telegram Channel: @CodeWriter21

Aparat Channel: CodeWriter21

License

License

apache-2.0

Donate

In order to support this project you can donate some crypto of your choice 8D

Donate Addresses

Or if you can't, give this project a star on GitHub :)

References

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

whois21-1.3.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

whois21-1.3.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file whois21-1.3.0.tar.gz.

File metadata

  • Download URL: whois21-1.3.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for whois21-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c7f7c27e300b09adba63ebcf4ee95bccf1ad97ae40739583bc21ba817dc53776
MD5 1a268af8bc1129f58d5eb515c37ff705
BLAKE2b-256 b80e07dec0ca09a3f775eabb23bf3431952d9a183d9685dec287e1a855882437

See more details on using hashes here.

File details

Details for the file whois21-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: whois21-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for whois21-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63e77973cb95bbf0d5271c71be6c93560dcd9e8057d394e448553eb5819e80c4
MD5 6e112a68ddce700016e5633649579405
BLAKE2b-256 8f707e2fce50af8e755439667a10123284bb7eadfe9c40244d824c1ce7eed58c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page