Advertisement
E-werd

ITFlow whois example

Oct 10th, 2023 (edited)
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import whois
  3. from contextlib import redirect_stderr
  4. from os import devnull
  5.  
  6. def get_itflow_dict(domain: whois.Domain) -> dict:
  7.     d: dict     = {}
  8.     format: str = "%a, %d %b %Y %H:%M:%S UTC"
  9.  
  10.     d.update({"address":            [domain.registrant_country]})
  11.     d.update({"creation_date":      domain.creation_date.strftime(format=format)})
  12.     d.update({"dnssec":             domain.dnssec})
  13.     d.update({"domain_name":        domain.name})
  14.     d.update({"email":              domain.emails})
  15.     d.update({"expiration_date":    domain.expiration_date.strftime(format=format)})
  16.     d.update({"name":               domain.name})
  17.     d.update({"name_servers":       domain.name_servers})
  18.     d.update({"registrant_name":    domain.registrant})
  19.  
  20.     return d
  21.  
  22. domain: str = "sru.edu"
  23.  
  24. with open(devnull, 'w') as fnull:
  25.     with redirect_stderr(fnull) as err: # Because of some dumb stderr output in whois lib
  26.         w: whois.Domain = whois.query(domain=domain)
  27.         d: dict         = get_itflow_dict(domain=w)
  28.  
  29.         # print(w.__dict__) # Raw dict from whois lib
  30.         print(d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement