whois/__init__.py
changeset 25 f3c0a9a442aa
parent 23 5c3e1a2c9c9a
child 29 1ebe960587b1
equal deleted inserted replaced
24:16f17c400a70 25:f3c0a9a442aa
     6 from whois import NICClient
     6 from whois import NICClient
     7 
     7 
     8 
     8 
     9 def whois(url):
     9 def whois(url):
    10     # clean domain to expose netloc
    10     # clean domain to expose netloc
    11     domain = extract_domain(url)
    11     ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url)
       
    12     if ip_match:
       
    13         domain = url
       
    14     else:
       
    15         domain = extract_domain(url)
    12     try:
    16     try:
    13         # try native whois command first
    17         # try native whois command first
    14         r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)
    18         r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)
    15         text = r.stdout.read()
    19         text = r.stdout.read()
    16     except OSError:
    20     except OSError: