Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import whois
- from contextlib import redirect_stderr
- from os import devnull
- def get_itflow_dict(domain: whois.Domain) -> dict:
- d: dict = {}
- format: str = "%a, %d %b %Y %H:%M:%S UTC"
- d.update({"address": [domain.registrant_country]})
- d.update({"creation_date": domain.creation_date.strftime(format=format)})
- d.update({"dnssec": domain.dnssec})
- d.update({"domain_name": domain.name})
- d.update({"email": domain.emails})
- d.update({"expiration_date": domain.expiration_date.strftime(format=format)})
- d.update({"name": domain.name})
- d.update({"name_servers": domain.name_servers})
- d.update({"registrant_name": domain.registrant})
- return d
- domain: str = "sru.edu"
- with open(devnull, 'w') as fnull:
- with redirect_stderr(fnull) as err: # Because of some dumb stderr output in whois lib
- w: whois.Domain = whois.query(domain=domain)
- d: dict = get_itflow_dict(domain=w)
- # print(w.__dict__) # Raw dict from whois lib
- print(d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement