equal
deleted
inserted
replaced
10 import os |
10 import os |
11 import subprocess |
11 import subprocess |
12 import socket |
12 import socket |
13 from .parser import WhoisEntry |
13 from .parser import WhoisEntry |
14 from .whois import NICClient |
14 from .whois import NICClient |
|
15 |
15 |
16 |
16 |
17 |
17 def whois(url, command=False): |
18 def whois(url, command=False): |
18 # clean domain to expose netloc |
19 # clean domain to expose netloc |
19 ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url) |
20 ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url) |
32 r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE) |
33 r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE) |
33 text = r.stdout.read() |
34 text = r.stdout.read() |
34 else: |
35 else: |
35 # try builtin client |
36 # try builtin client |
36 nic_client = NICClient() |
37 nic_client = NICClient() |
37 text = nic_client.whois_lookup(None, domain, 0) |
38 text = nic_client.whois_lookup(None, domain.encode('idna'), 0) |
38 return WhoisEntry.load(domain, text) |
39 return WhoisEntry.load(domain, text) |
39 |
40 |
40 |
41 |
41 def extract_domain(url): |
42 def extract_domain(url): |
42 """Extract the domain from the given URL |
43 """Extract the domain from the given URL |