Coderja 1 month ago
Coderja #tutorial

Domain WHOIS by Python3

Python script to perform WHOIS lookups on a list of domains, along with explanations and considerations

import whois


def bulk_whois_lookup(domains):
    results = {}
    for domain in domains:
        try:
            whois_data = whois.whois(domain)
            results[domain] = whois_data
        except whois.parser.PywhoisError:
            results[domain] = "WHOIS data not available"
    return results


# Your domain list
domains = ["google.com", "example.org", "nonexistentdomain.net"]

# Perform WHOIS lookups
whois_results = bulk_whois_lookup(domains)

# Print the results in a user-friendly way
for domain, data in whois_results.items():
    print(f"\nWHOIS information for {domain}:")
    if isinstance(data, str):
        print(data)
    else:
        for key, value in data.items():
            print(f"{key}: {value}")

How it Works:

  1. Import the whois library: This library provides functions to interact with WHOIS servers. Make sure you have it installed (pip install python-whois).
  • bulk_whois_lookup function:Takes a list of domains as input.
  • Iterates through each domain.
  • Tries to retrieve WHOIS data using whois.whois(domain).
  • If successful, stores the data in the results dictionary with the domain as the key.
  • If WHOIS data is not found, it stores the string "WHOIS data not available."
  • Returns the results dictionary.
  1. Domain list: Define your list of domains.
  2. Perform lookups: Call the bulk_whois_lookup function with your domain list.
  3. Display results: Loop through the results dictionary and print the information for each domain in a formatted manner. If data is not available, it prints the corresponding message.

Key Considerations:

  • Rate Limiting: WHOIS servers might have rate limits to prevent abuse. If you're performing a large number of lookups, implement a delay between requests to avoid being blocked.
  • Data Parsing: The whois library attempts to parse the raw WHOIS response. However, responses can vary in format, so handle potential parsing errors gracefully.
  • Data Accuracy: WHOIS data is self-reported by domain registrants and may not always be accurate or complete.
  • Privacy Protection: Some domains have privacy protection enabled, which can mask the true owner's information.

Example Output:

WHOIS information for google.com: ... (WHOIS data for google.com) ... WHOIS information for example.org: ... (WHOIS data for example.org) ... WHOIS information for nonexistentdomain.net: WHOIS data not available

Advanced Options:

  • Custom Output: You can customize how you display the results. For example, save them to a CSV file, a database, or use a more structured output format (e.g., JSON).
  • Specific Fields: Extract only the specific fields you're interested in (e.g., registrar, expiration date).


Url Extractor Python Script

Url Extractor Python Script

defaultuser.png
Coderja
1 month ago
TMDB Movie Scraper

TMDB Movie Scraper

defaultuser.png
Coderja
1 month ago

Bulk post Wordpress Via xmlrpc Menggunakan Python

defaultuser.png
Coderja
1 month ago

Check File

This script will help you efficiently check for the existence of file across multiple URLs...

defaultuser.png
Coderja
1 month ago
Reverse Domain

Reverse Domain

defaultuser.png
Coderja
1 month ago