equal
deleted
inserted
replaced
|
1 from __future__ import print_function |
|
2 from __future__ import absolute_import |
|
3 from __future__ import unicode_literals |
|
4 from __future__ import division |
|
5 from future import standard_library |
|
6 standard_library.install_aliases() |
|
7 from builtins import * |
1 import re |
8 import re |
2 import sys |
9 import sys |
3 import os |
10 import os |
4 import subprocess |
11 import subprocess |
5 import socket |
12 import socket |
6 from parser import WhoisEntry |
13 from .parser import WhoisEntry |
7 from whois import NICClient |
14 from .whois import NICClient |
8 |
15 |
9 |
16 |
10 def whois(url, command=False): |
17 def whois(url, command=False): |
11 # clean domain to expose netloc |
18 # clean domain to expose netloc |
12 ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url) |
19 ip_match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", url) |
48 line.lower().strip() |
55 line.lower().strip() |
49 for line in open(tlds_path).readlines() |
56 for line in open(tlds_path).readlines() |
50 if not line.startswith('#') |
57 if not line.startswith('#') |
51 ] |
58 ] |
52 |
59 |
53 if type(url) is not unicode: |
60 if type(url) is not str: |
54 url = url.decode('utf-8') |
61 url = url.decode('utf-8') |
55 url = re.sub('^.*://', '', url.encode('idna')).split('/')[0].lower() |
62 url = re.sub('^.*://', '', url.encode('idna')).split('/')[0].lower() |
56 domain = [] |
63 domain = [] |
57 |
64 |
58 for section in url.split('.'): |
65 for section in url.split('.'): |
65 |
72 |
66 if __name__ == '__main__': |
73 if __name__ == '__main__': |
67 try: |
74 try: |
68 url = sys.argv[1] |
75 url = sys.argv[1] |
69 except IndexError: |
76 except IndexError: |
70 print 'Usage: %s url' % sys.argv[0] |
77 print('Usage: %s url' % sys.argv[0]) |
71 else: |
78 else: |
72 print whois(url) |
79 print(whois(url)) |