Skip to main content

A package to retrieve WHOIS and IP information

Project description

MyInfo

MyInfo is a Python library for retrieving and formatting WHOIS and IP geolocation information. It allows you to easily get domain-related data such as registrar, creation date, expiry date, and DNS information, as well as IP geolocation details like city, country, and organization.

Features

  • Fetch WHOIS information for a domain.
  • Resolve a domain to its IP address.
  • Retrieve geolocation information for an IP address.
  • Clean and simple API for integration into any Python project.

Installation

pip install myinfo

Usage

You can use the package to retrieve both WHOIS and IP information for any domain.

Example Usage

1. WHOIS Information

To fetch and format WHOIS information for a domain :

import myinfo

# Get WHOIS information
domain = "google.com"
whois_info = myinfo.get_whois_info(domain)

# Check for any errors
if 'error' not in whois_info:
    # Format WHOIS information
    formatted_whois = myinfo.format_whois_info(whois_info)
    
    # Example of displaying some information
    print(f"Domain Name: {formatted_whois['domain_name']}")
    print(f"Registrar: {formatted_whois['registrar']}")
    print(f"Creation Date: {formatted_whois['creation_date']}")
    print(f"Registry Expiry Date: {formatted_whois['registry_expiry_date']}")
    print(f"Name Servers: {formatted_whois['name_servers']}")
else:
    print(whois_info['error'])

2. IP Geolocation Information

To resolve a domain to its IP and retrieve geolocation information for that IP :

import myinfo

# Resolve domain to IP
domain = "google.com"
ip_address = myinfo.resolve_domain_to_ip(domain)

# Check for errors in resolving IP
if isinstance(ip_address, dict) and 'error' in ip_address:
    print(ip_address['error'])
else:
    # Get IP Geolocation information
    ip_info = myinfo.get_ip_geolocation(ip_address)
    
    # Check for errors in fetching IP info
    if 'error' not in ip_info:
        # Format IP geolocation information
        formatted_ip_info = myinfo.format_ip_info(ip_info)
        
        # Example of displaying some information
        print(f"IP Address: {formatted_ip_info['ip_address']}")
        print(f"City: {formatted_ip_info['city']}")
        print(f"Country: {formatted_ip_info['country']}")
        print(f"Organization: {formatted_ip_info['organization']}")
    else:
        print(ip_info['error'])

Functions

get_whois_info(domain)

  • Retrieves WHOIS information for the given domain.
  • Parameters:
    • domain (str): The domain name to get WHOIS information for.
  • Returns:
    • A dictionary containing the WHOIS information or an error message.

format_whois_info(domain_info)

  • Formats WHOIS information into a readable dictionary.
  • Parameters:
    • domain_info (dict): The raw WHOIS data retrieved from the get_whois_info() function.
  • Returns:
    • A dictionary containing formatted WHOIS data.

resolve_domain_to_ip(domain)

  • Resolves a domain to its corresponding IP address.
  • Parameters:
    • domain (str): The domain name to resolve.
  • Returns:
    • The IP address (str) or an error message (dict).

get_ip_geolocation(ip_address)

  • Retrieves geolocation information for a given IP address.
  • Parameters:
    • ip_address (str): The IP address to get geolocation info for.
  • Returns:
    • A dictionary containing IP geolocation information or an error message.

format_ip_info(ip_info)

  • Formats IP geolocation information into a readable dictionary.
  • Parameters:
    • ip_info (dict): The raw geolocation data retrieved from the get_ip_geolocation() function.
  • Returns:
    • A dictionary containing formatted IP geolocation data.

Example Output

For the domain google.com :

Domain Name: google.com  
Registrar: MarkMonitor Inc.  
Creation Date: 1997-09-15T04:00:00Z  
Registry Expiry Date: 2028-09-14T04:00:00Z  
Name Servers: ['NS1.GOOGLE.COM', 'NS2.GOOGLE.COM', 'NS3.GOOGLE.COM', 'NS4.GOOGLE.COM']

IP Address: 172.217.12.14  
City: Mountain View  
Country: US  
Organization: GOOGLE

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

myinfo-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

myinfo-1.0.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file myinfo-1.0.0.tar.gz.

File metadata

  • Download URL: myinfo-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for myinfo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6b4ef2152cd53e3e499de5eb68dda4a8444f8ffd1e6a5fb6be216ba3fa18ab00
MD5 57191053091f08ad6bc9e5075cb73cea
BLAKE2b-256 40e5f1ef2a826dc6b02755ca61f81f4443cf78b6ec1e86c9f9af47ccc68e620f

See more details on using hashes here.

File details

Details for the file myinfo-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: myinfo-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for myinfo-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6529df4795670ca639282b53218c1599547649bb4cc1a5c71ece1aa7569e2380
MD5 79e138152bcbe7ed8ac927cd7156bd35
BLAKE2b-256 1dc6cda7f6ec1d6d3b08b99f046fd01ece790e5e3a4f3e8148fbeb8f805d3ea3

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