The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a tool to track domain name expiration

To build a tool that tracks domain name expiration, you’ll need to create a system that performs WHOIS lookups on domain names, extracts the expiration dates, stores the data, and periodically checks for updates. Below is a basic implementation plan followed by a Python-based example using whois and schedule modules.


Key Features of the Tool

  1. Input list of domain names.

  2. Perform WHOIS lookup.

  3. Extract expiration dates.

  4. Store and log data (CSV or database).

  5. Notify or flag domains nearing expiration.


Technology Stack

  • Language: Python

  • Libraries: whois, schedule, datetime, csv, smtplib (optional for email alerts)

  • Storage: CSV or SQLite (for small to medium-scale usage)


Step-by-Step Implementation

Step 1: Install Required Libraries

bash
pip install python-whois schedule

Step 2: Python Script to Track Domain Expiry

python
import whois import csv import datetime import schedule import time DOMAINS_FILE = 'domains.csv' LOG_FILE = 'domain_expiry_log.csv' WARNING_DAYS = 30 # Days before expiry to trigger a warning def load_domains(): with open(DOMAINS_FILE, newline='') as f: return [row[0].strip() for row in csv.reader(f) if row] def check_expiration(domain): try: info = whois.whois(domain) expiration = info.expiration_date # Some WHOIS servers return a list of dates if isinstance(expiration, list): expiration = expiration[0] if expiration: days_left = (expiration - datetime.datetime.now()).days return expiration.strftime('%Y-%m-%d'), days_left else: return "Unknown", "Unknown" except Exception as e: return "Error", str(e) def log_results(results): with open(LOG_FILE, 'a', newline='') as f: writer = csv.writer(f) for result in results: writer.writerow(result) def check_domains(): print(f"[{datetime.datetime.now()}] Checking domains...") domains = load_domains() results = [] for domain in domains: expiry, days_left = check_expiration(domain) status = "OK" if isinstance(days_left, int) and days_left < WARNING_DAYS: status = "EXPIRING SOON" elif days_left == "Unknown" or days_left == "Error": status = "ERROR" results.append([domain, expiry, days_left, status]) log_results(results) print(f"Checked {len(domains)} domains.") # Schedule to run once a day schedule.every().day.at("09:00").do(check_domains) if __name__ == '__main__': check_domains() # Run immediately at start while True: schedule.run_pending() time.sleep(60)

Step 3: Setup the CSV Input File

Create a domains.csv file with one domain per line:

example.com openai.com yourdomain.net

Step 4: Output Format

The script will append results in domain_expiry_log.csv like this:

example.com,2025-08-15,89,OK yourdomain.net,2025-06-10,23,EXPIRING SOON

Optional Enhancements

  • Email Alerts: Use smtplib to notify when domains are close to expiration.

  • Web Interface: Integrate with Flask or Django for a frontend.

  • Database Storage: Replace CSV with SQLite or PostgreSQL for scalability.

  • Dockerize the app for deployment or use as a cron job.

Let me know if you want a version with email notifications or a web dashboard.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About