In this tutorial I will show you how to calculate remaining days of domain to expire.
Install Python package:
pip install python-whois
PYTHON CODE:
import datetime import whois def get_whois_info(domain_name): domain_info = whois.whois(domain_name) expiration_date = domain_info.expiration_date[0] last_updated = domain_info.last_updated registrar = domain_info.registrar remaining_days=(expiration_date-datetime.datetime.now()).days return { 'expiration_date': expiration_date , 'last_updated': last_updated, 'registrar': registrar, 'name': domain_name, 'remaining_days':remaining_days } # Example domain domain_name = 'quicgen.com' # Get WHOIS information domain_info = get_whois_info(domain_name) for key, value in domain_info.items(): print(key,':', value)
I obtain the expiration date from Whois module. To get the no. of days I subtract expiration date from current date and time.
OUTPUT:
![calculate days of domain name](https://www.infinetsoft.com/Uploads/20231010221549calculate_days_of_domain.png)
VIDEO GUIDE:
Post your comments / questions
Recent Article
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
Related Article