| author | Amy Woodehy <amywoodehy@gmail.com> |
| Wed, 12 Aug 2015 11:41:38 +0600 | |
| changeset 53 | e2eaf1755fce |
| parent 50 | 9b1df2267f84 |
| child 56 | ff15b368adaf |
| permissions | -rw-r--r-- |
|
37
8ad334b5363b
Add .рф TLD expiration_date regex
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
30
diff
changeset
|
1 |
# coding=utf-8 |
|
46
b3862a45fdad
Always import datetime no matter if dateutil is present
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
44
diff
changeset
|
2 |
from datetime import datetime |
|
37
8ad334b5363b
Add .рф TLD expiration_date regex
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
30
diff
changeset
|
3 |
|
| 0 | 4 |
# parser.py - Module for parsing whois response data |
5 |
# Copyright (c) 2008 Andrey Petrov |
|
6 |
# |
|
7 |
# This module is part of pywhois and is released under |
|
8 |
# the MIT license: http://www.opensource.org/licenses/mit-license.php |
|
9 |
||
10 |
import re |
|
|
39
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
11 |
try: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
12 |
import dateutil.parser as dp |
|
41
8772587c32a5
Fix bad import in parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
40
diff
changeset
|
13 |
from time_zones import tz_data |
|
39
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
14 |
DATEUTIL = True |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
15 |
except ImportError: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
16 |
DATEUTIL = False |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
17 |
|
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
18 |
KNOWN_FORMATS = [ |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
19 |
'%d-%b-%Y', # 02-jan-2000 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
20 |
'%Y-%m-%d', # 2000-01-02 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
21 |
'%d.%m.%Y', # 2.1.2000 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
22 |
'%Y.%m.%d', # 2000.01.02 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
23 |
'%Y/%m/%d', # 2000/01/02 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
24 |
'%d/%m/%Y', # 02/01/2013 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
25 |
'%Y. %m. %d.', # 2000. 01. 02. |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
26 |
'%Y.%m.%d %H:%M:%S', # 2014.03.08 10:28:24 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
27 |
'%d-%b-%Y %H:%M:%S %Z', # 24-Jul-2009 13:20:03 UTC |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
28 |
'%a %b %d %H:%M:%S %Z %Y', # Tue Jun 21 23:59:59 GMT 2011 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
29 |
'%Y-%m-%dT%H:%M:%SZ', # 2007-01-26T19:10:31Z |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
30 |
'%Y-%m-%dT%H:%M:%S%z', # 2013-12-06T08:17:22-0800 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
31 |
'%Y-%m-%d %H:%M:%SZ', # 2000-08-22 18:55:20Z |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
32 |
'%Y-%m-%d %H:%M:%S', # 2000-08-22 18:55:20 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
33 |
'%d %b %Y %H:%M:%S', # 08 Apr 2013 05:44:00 |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
34 |
'%d/%m/%Y %H:%M:%S', # 23/04/2015 12:00:07 EEST |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
35 |
'%d/%m/%Y %H:%M:%S %Z', # 23/04/2015 12:00:07 EEST |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
36 |
'%d/%m/%Y %H:%M:%S.%f %Z', # 23/04/2015 12:00:07.619546 EEST |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
37 |
] |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
38 |
|
| 0 | 39 |
|
40 |
class PywhoisError(Exception): |
|
41 |
pass |
|
42 |
||
43 |
||
|
39
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
44 |
def datetime_parse(s): |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
45 |
for known_format in KNOWN_FORMATS: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
46 |
try: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
47 |
s = datetime.strptime(s.strip(), known_format) |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
48 |
break |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
49 |
except ValueError as e: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
50 |
pass # Wrong format, keep trying |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
51 |
return s |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
52 |
|
|
43
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
53 |
def cast_date(s, dayfirst=False, yearfirst=False): |
| 5 | 54 |
"""Convert any date string found in WHOIS to a datetime object. |
| 0 | 55 |
""" |
|
39
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
56 |
if DATEUTIL: |
| 0 | 57 |
try: |
|
43
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
58 |
return dp.parse( |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
59 |
s.strip(), |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
60 |
tzinfos=tz_data, |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
61 |
dayfirst=dayfirst, |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
62 |
yearfirst=yearfirst |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
63 |
).replace(tzinfo=None) |
|
39
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
64 |
except Exception: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
65 |
return datetime_parse(s) |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
66 |
else: |
|
68375a768598
Better date parsing support if python-dateutil is available
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
37
diff
changeset
|
67 |
return datetime_parse(s) |
| 0 | 68 |
|
69 |
||
| 48 | 70 |
class WhoisEntry(dict): |
| 0 | 71 |
"""Base class for parsing a Whois entries. |
72 |
""" |
|
73 |
# regular expressions to extract domain data from whois profile |
|
74 |
# child classes will override this |
|
75 |
_regex = {
|
|
| 47 | 76 |
'domain_name': 'Domain Name:\s?(.+)', |
77 |
'registrar': 'Registrar:\s?(.+)', |
|
78 |
'whois_server': 'Whois Server:\s?(.+)', |
|
79 |
'referral_url': 'Referral URL:\s?(.+)', # http url of whois_server |
|
80 |
'updated_date': 'Updated Date:\s?(.+)', |
|
81 |
'creation_date': 'Creation Date:\s?(.+)', |
|
82 |
'expiration_date': 'Expir\w+ Date:\s?(.+)', |
|
83 |
'name_servers': 'Name Server:\s?(.+)', # list of name servers |
|
84 |
'status': 'Status:\s?(.+)', # list of statuses |
|
85 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email s
|
|
86 |
'dnssec': 'dnssec:\s*([\S]+)', |
|
87 |
'name': 'Registrant Name:\s*(.+)', |
|
88 |
'org': 'Registrant\s*Organization:\s*(.+)', |
|
89 |
'address': 'Registrant Street:\s*(.+)', |
|
90 |
'city': 'Registrant City:\s*(.+)', |
|
91 |
'state': 'Registrant State/Province:\s*(.+)', |
|
92 |
'zipcode': 'Registrant Postal Code:\s*(.+)', |
|
93 |
'country': 'Registrant Country:\s*(.+)', |
|
| 0 | 94 |
} |
|
43
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
95 |
dayfirst = False |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
96 |
yearfirst = False |
| 0 | 97 |
|
98 |
def __init__(self, domain, text, regex=None): |
|
| 47 | 99 |
if 'This TLD has no whois server, but you can access the whois database at' in text: |
100 |
raise PywhoisError(text) |
|
101 |
else: |
|
102 |
self.domain = domain |
|
103 |
self.text = text |
|
104 |
if regex is not None: |
|
105 |
self._regex = regex |
|
| 48 | 106 |
self.parse() |
| 0 | 107 |
|
| 48 | 108 |
def parse(self): |
| 0 | 109 |
"""The first time an attribute is called it will be calculated here. |
110 |
The attribute is then set to be accessed directly by subsequent calls. |
|
111 |
""" |
|
| 48 | 112 |
for attr, regex in self._regex.items(): |
113 |
if regex: |
|
| 47 | 114 |
values = [] |
| 48 | 115 |
for value in re.findall(regex, self.text, re.IGNORECASE): |
| 47 | 116 |
if isinstance(value, basestring): |
117 |
# try casting to date format |
|
118 |
value = cast_date(value.strip(), |
|
119 |
dayfirst=self.dayfirst, |
|
120 |
yearfirst=self.yearfirst) |
|
121 |
if value and value not in values: |
|
122 |
# avoid duplicates |
|
123 |
values.append(value) |
|
124 |
if len(values) == 1: |
|
125 |
values = values[0] |
|
126 |
elif not values: |
|
127 |
values = None |
|
| 16 | 128 |
|
| 48 | 129 |
self[attr] = values |
| 0 | 130 |
|
131 |
||
| 48 | 132 |
def __setitem__(self, name, value): |
133 |
super(WhoisEntry, self).__setitem__(name, value) |
|
134 |
setattr(self, name, value) |
|
| 24 | 135 |
|
| 0 | 136 |
|
137 |
@staticmethod |
|
138 |
def load(domain, text): |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
139 |
"""Given whois output in ``text``, return an instance of ``WhoisEntry`` |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
140 |
that represents its parsed contents. |
| 0 | 141 |
""" |
142 |
if text.strip() == 'No whois server is known for this kind of object.': |
|
143 |
raise PywhoisError(text) |
|
144 |
||
| 10 | 145 |
if domain.endswith('.com'):
|
| 0 | 146 |
return WhoisCom(domain, text) |
| 10 | 147 |
elif domain.endswith('.net'):
|
| 0 | 148 |
return WhoisNet(domain, text) |
| 10 | 149 |
elif domain.endswith('.org'):
|
| 0 | 150 |
return WhoisOrg(domain, text) |
| 10 | 151 |
elif domain.endswith('.name'):
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
152 |
return WhoisName(domain, text) |
| 10 | 153 |
elif domain.endswith('.me'):
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
154 |
return WhoisMe(domain, text) |
| 17 | 155 |
elif domain.endswith('.au'):
|
156 |
return WhoisAU(domain, text) |
|
| 10 | 157 |
elif domain.endswith('.ru'):
|
158 |
return WhoisRu(domain, text) |
|
159 |
elif domain.endswith('.us'):
|
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
160 |
return WhoisUs(domain, text) |
| 10 | 161 |
elif domain.endswith('.uk'):
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
162 |
return WhoisUk(domain, text) |
| 10 | 163 |
elif domain.endswith('.fr'):
|
| 4 | 164 |
return WhoisFr(domain, text) |
| 47 | 165 |
elif domain.endswith('.nl'):
|
166 |
return WhoisNl(domain, text) |
|
| 10 | 167 |
elif domain.endswith('.fi'):
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
168 |
return WhoisFi(domain, text) |
| 10 | 169 |
elif domain.endswith('.jp'):
|
| 5 | 170 |
return WhoisJp(domain, text) |
| 11 | 171 |
elif domain.endswith('.pl'):
|
172 |
return WhoisPl(domain, text) |
|
| 15 | 173 |
elif domain.endswith('.br'):
|
| 21 | 174 |
return WhoisBr(domain, text) |
| 20 | 175 |
elif domain.endswith('.eu'):
|
| 21 | 176 |
return WhoisEu(domain, text) |
| 19 | 177 |
elif domain.endswith('.kr'):
|
| 21 | 178 |
return WhoisKr(domain, text) |
179 |
elif domain.endswith('.pt'):
|
|
180 |
return WhoisPt(domain, text) |
|
|
26
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
181 |
elif domain.endswith('.bg'):
|
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
182 |
return WhoisBg(domain, text) |
| 47 | 183 |
elif domain.endswith('.de'):
|
184 |
return WhoisDe(domain, text) |
|
185 |
elif domain.endswith('.ca'):
|
|
186 |
return WhoisCa(domain, text) |
|
187 |
elif domain.endswith('.be'):
|
|
188 |
return WhoisBe(domain, text) |
|
|
37
8ad334b5363b
Add .рф TLD expiration_date regex
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
30
diff
changeset
|
189 |
elif domain.endswith('.рф'):
|
|
8ad334b5363b
Add .рф TLD expiration_date regex
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
30
diff
changeset
|
190 |
return WhoisRf(domain, text) |
|
44
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
191 |
elif domain.endswith('.info'):
|
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
192 |
return WhoisInfo(domain, text) |
|
53
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
193 |
elif domain.endswith('.su'):
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
194 |
return WhoisSu(domain, text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
195 |
elif domain.endswith('.kg'):
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
196 |
return WhoisKg(domain, text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
197 |
elif domain.endswith('.io'):
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
198 |
return WhoisIo(domain, text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
199 |
elif domain.endswith('.biz'):
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
200 |
return WhoisBiz(domain, text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
201 |
elif domain.endswith('.mobi'):
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
202 |
return WhoisMobi(domain, text) |
| 0 | 203 |
else: |
204 |
return WhoisEntry(domain, text) |
|
205 |
||
206 |
||
207 |
class WhoisCom(WhoisEntry): |
|
208 |
"""Whois parser for .com domains |
|
209 |
""" |
|
210 |
def __init__(self, domain, text): |
|
211 |
if 'No match for "' in text: |
|
212 |
raise PywhoisError(text) |
|
213 |
else: |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
214 |
WhoisEntry.__init__(self, domain, text) |
| 0 | 215 |
|
| 4 | 216 |
|
| 0 | 217 |
class WhoisNet(WhoisEntry): |
218 |
"""Whois parser for .net domains |
|
219 |
""" |
|
220 |
def __init__(self, domain, text): |
|
221 |
if 'No match for "' in text: |
|
222 |
raise PywhoisError(text) |
|
223 |
else: |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
224 |
WhoisEntry.__init__(self, domain, text) |
| 0 | 225 |
|
| 4 | 226 |
|
| 0 | 227 |
class WhoisOrg(WhoisEntry): |
228 |
"""Whois parser for .org domains |
|
229 |
""" |
|
|
44
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
230 |
regex = {
|
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
231 |
'domain_name': 'Domain Name:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
232 |
'registrar': 'Registrar:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
233 |
'whois_server': 'Whois Server:\s?(.+)', # empty usually |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
234 |
'referral_url': 'Referral URL:\s?(.+)', # http url of whois_server: empty usually |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
235 |
'updated_date': 'Updated Date:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
236 |
'creation_date': 'Creation Date:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
237 |
'expiration_date': 'Registry Expiry Date:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
238 |
'name_servers': 'Name Server:\s?(.+)', # list of name servers |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
239 |
'status': 'Status:\s?(.+)', # list of statuses |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
240 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
241 |
} |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
242 |
|
| 0 | 243 |
def __init__(self, domain, text): |
244 |
if text.strip() == 'NOT FOUND': |
|
245 |
raise PywhoisError(text) |
|
246 |
else: |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
247 |
WhoisEntry.__init__(self, domain, text) |
| 0 | 248 |
|
| 4 | 249 |
|
| 0 | 250 |
class WhoisRu(WhoisEntry): |
251 |
"""Whois parser for .ru domains |
|
252 |
""" |
|
253 |
regex = {
|
|
254 |
'domain_name': 'domain:\s*(.+)', |
|
255 |
'registrar': 'registrar:\s*(.+)', |
|
256 |
'creation_date': 'created:\s*(.+)', |
|
257 |
'expiration_date': 'paid-till:\s*(.+)', |
|
258 |
'name_servers': 'nserver:\s*(.+)', # list of name servers |
|
259 |
'status': 'state:\s*(.+)', # list of statuses |
|
260 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
|
| 47 | 261 |
'org': 'org:\s*(.+)' |
| 0 | 262 |
} |
263 |
||
264 |
def __init__(self, domain, text): |
|
265 |
if text.strip() == 'No entries found': |
|
266 |
raise PywhoisError(text) |
|
267 |
else: |
|
268 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
269 |
||
| 4 | 270 |
|
| 47 | 271 |
class WhoisNl(WhoisEntry): |
272 |
"""Whois parser for .nl domains |
|
273 |
""" |
|
274 |
regex = {
|
|
275 |
'name': None, |
|
276 |
'address': None, |
|
277 |
'zip_code': None, |
|
278 |
'city': None, |
|
279 |
'country': None |
|
280 |
} |
|
281 |
||
282 |
def __init__(self, domain, text): |
|
283 |
if text.endswith('is free'):
|
|
284 |
raise PywhoisError(text) |
|
285 |
else: |
|
286 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
287 |
||
288 |
match = re.compile('Registrar:(.*?)DNSSEC', re.DOTALL).search(text)
|
|
289 |
if match: |
|
290 |
lines = match.groups()[0].strip().splitlines() |
|
291 |
self.name = lines[0] |
|
292 |
self.address = lines[1] |
|
293 |
if len(lines) == 4: |
|
294 |
self.zip_code, _, self.city = lines[2].partition(' ')
|
|
295 |
self.country = lines[-1] |
|
296 |
||
297 |
||
| 0 | 298 |
class WhoisName(WhoisEntry): |
299 |
"""Whois parser for .name domains |
|
300 |
""" |
|
301 |
regex = {
|
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
302 |
'domain_name_id': 'Domain Name ID:\s*(.+)', |
| 0 | 303 |
'domain_name': 'Domain Name:\s*(.+)', |
304 |
'registrar_id': 'Sponsoring Registrar ID:\s*(.+)', |
|
305 |
'registrar': 'Sponsoring Registrar:\s*(.+)', |
|
306 |
'registrant_id': 'Registrant ID:\s*(.+)', |
|
307 |
'admin_id': 'Admin ID:\s*(.+)', |
|
308 |
'technical_id': 'Tech ID:\s*(.+)', |
|
309 |
'billing_id': 'Billing ID:\s*(.+)', |
|
310 |
'creation_date': 'Created On:\s*(.+)', |
|
311 |
'expiration_date': 'Expires On:\s*(.+)', |
|
312 |
'updated_date': 'Updated On:\s*(.+)', |
|
313 |
'name_server_ids': 'Name Server ID:\s*(.+)', # list of name server ids |
|
314 |
'name_servers': 'Name Server:\s*(.+)', # list of name servers |
|
315 |
'status': 'Domain Status:\s*(.+)', # list of statuses |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
316 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
317 |
|
| 0 | 318 |
def __init__(self, domain, text): |
| 47 | 319 |
if 'No match for ' in text: |
| 0 | 320 |
raise PywhoisError(text) |
321 |
else: |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
322 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
323 |
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
324 |
|
| 0 | 325 |
class WhoisUs(WhoisEntry): |
326 |
"""Whois parser for .us domains |
|
327 |
""" |
|
328 |
regex = {
|
|
329 |
'domain_name': 'Domain Name:\s*(.+)', |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
330 |
'domain__id': 'Domain ID:\s*(.+)', |
| 0 | 331 |
'registrar': 'Sponsoring Registrar:\s*(.+)', |
332 |
'registrar_id': 'Sponsoring Registrar IANA ID:\s*(.+)', |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
333 |
'registrar_url': 'Registrar URL \(registration services\):\s*(.+)', |
| 0 | 334 |
'status': 'Domain Status:\s*(.+)', # list of statuses |
335 |
'registrant_id': 'Registrant ID:\s*(.+)', |
|
336 |
'registrant_name': 'Registrant Name:\s*(.+)', |
|
337 |
'registrant_address1': 'Registrant Address1:\s*(.+)', |
|
338 |
'registrant_address2': 'Registrant Address2:\s*(.+)', |
|
339 |
'registrant_city': 'Registrant City:\s*(.+)', |
|
340 |
'registrant_state_province': 'Registrant State/Province:\s*(.+)', |
|
341 |
'registrant_postal_code': 'Registrant Postal Code:\s*(.+)', |
|
342 |
'registrant_country': 'Registrant Country:\s*(.+)', |
|
343 |
'registrant_country_code': 'Registrant Country Code:\s*(.+)', |
|
344 |
'registrant_phone_number': 'Registrant Phone Number:\s*(.+)', |
|
345 |
'registrant_email': 'Registrant Email:\s*(.+)', |
|
346 |
'registrant_application_purpose': 'Registrant Application Purpose:\s*(.+)', |
|
347 |
'registrant_nexus_category': 'Registrant Nexus Category:\s*(.+)', |
|
348 |
'admin_id': 'Administrative Contact ID:\s*(.+)', |
|
349 |
'admin_name': 'Administrative Contact Name:\s*(.+)', |
|
350 |
'admin_address1': 'Administrative Contact Address1:\s*(.+)', |
|
351 |
'admin_address2': 'Administrative Contact Address2:\s*(.+)', |
|
352 |
'admin_city': 'Administrative Contact City:\s*(.+)', |
|
353 |
'admin_state_province': 'Administrative Contact State/Province:\s*(.+)', |
|
354 |
'admin_postal_code': 'Administrative Contact Postal Code:\s*(.+)', |
|
355 |
'admin_country': 'Administrative Contact Country:\s*(.+)', |
|
356 |
'admin_country_code': 'Administrative Contact Country Code:\s*(.+)', |
|
357 |
'admin_phone_number': 'Administrative Contact Phone Number:\s*(.+)', |
|
358 |
'admin_email': 'Administrative Contact Email:\s*(.+)', |
|
359 |
'admin_application_purpose': 'Administrative Application Purpose:\s*(.+)', |
|
360 |
'admin_nexus_category': 'Administrative Nexus Category:\s*(.+)', |
|
361 |
'billing_id': 'Billing Contact ID:\s*(.+)', |
|
362 |
'billing_name': 'Billing Contact Name:\s*(.+)', |
|
363 |
'billing_address1': 'Billing Contact Address1:\s*(.+)', |
|
364 |
'billing_address2': 'Billing Contact Address2:\s*(.+)', |
|
365 |
'billing_city': 'Billing Contact City:\s*(.+)', |
|
366 |
'billing_state_province': 'Billing Contact State/Province:\s*(.+)', |
|
367 |
'billing_postal_code': 'Billing Contact Postal Code:\s*(.+)', |
|
368 |
'billing_country': 'Billing Contact Country:\s*(.+)', |
|
369 |
'billing_country_code': 'Billing Contact Country Code:\s*(.+)', |
|
370 |
'billing_phone_number': 'Billing Contact Phone Number:\s*(.+)', |
|
371 |
'billing_email': 'Billing Contact Email:\s*(.+)', |
|
372 |
'billing_application_purpose': 'Billing Application Purpose:\s*(.+)', |
|
373 |
'billing_nexus_category': 'Billing Nexus Category:\s*(.+)', |
|
374 |
'tech_id': 'Technical Contact ID:\s*(.+)', |
|
375 |
'tech_name': 'Technical Contact Name:\s*(.+)', |
|
376 |
'tech_address1': 'Technical Contact Address1:\s*(.+)', |
|
377 |
'tech_address2': 'Technical Contact Address2:\s*(.+)', |
|
378 |
'tech_city': 'Technical Contact City:\s*(.+)', |
|
379 |
'tech_state_province': 'Technical Contact State/Province:\s*(.+)', |
|
380 |
'tech_postal_code': 'Technical Contact Postal Code:\s*(.+)', |
|
381 |
'tech_country': 'Technical Contact Country:\s*(.+)', |
|
382 |
'tech_country_code': 'Technical Contact Country Code:\s*(.+)', |
|
383 |
'tech_phone_number': 'Technical Contact Phone Number:\s*(.+)', |
|
384 |
'tech_email': 'Technical Contact Email:\s*(.+)', |
|
385 |
'tech_application_purpose': 'Technical Application Purpose:\s*(.+)', |
|
386 |
'tech_nexus_category': 'Technical Nexus Category:\s*(.+)', |
|
387 |
'name_servers': 'Name Server:\s*(.+)', # list of name servers |
|
388 |
'created_by_registrar': 'Created by Registrar:\s*(.+)', |
|
389 |
'last_updated_by_registrar': 'Last Updated by Registrar:\s*(.+)', |
|
390 |
'creation_date': 'Domain Registration Date:\s*(.+)', |
|
391 |
'expiration_date': 'Domain Expiration Date:\s*(.+)', |
|
392 |
'updated_date': 'Domain Last Updated Date:\s*(.+)', |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
393 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
394 |
|
| 0 | 395 |
def __init__(self, domain, text): |
396 |
if 'Not found:' in text: |
|
397 |
raise PywhoisError(text) |
|
398 |
else: |
|
399 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
400 |
|
| 11 | 401 |
|
402 |
class WhoisPl(WhoisEntry): |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
403 |
"""Whois parser for .pl domains |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
404 |
""" |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
405 |
regex = {
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
406 |
'domain_name': 'DOMAIN NAME:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
407 |
'registrar': 'REGISTRAR:\n\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
408 |
'registrar_url': 'URL:\s*(.+)', # not available |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
409 |
'status': 'Registration status:\n\s*(.+)', # not available |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
410 |
'registrant_name': 'Registrant:\n\s*(.+)', # not available |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
411 |
'creation_date': 'created:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
412 |
'expiration_date': 'renewal date:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
413 |
'updated_date': 'last modified:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
414 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
415 |
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
416 |
def __init__(self, domain, text): |
| 47 | 417 |
if 'No information available about domain name' in text: |
418 |
raise PywhoisError(text) |
|
419 |
else: |
|
420 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
421 |
||
422 |
||
423 |
class WhoisCa(WhoisEntry): |
|
424 |
"""Whois parser for .ca domains |
|
425 |
""" |
|
426 |
regex = {
|
|
427 |
'registrant_name': 'Name:\s*(.+)', |
|
428 |
'registrant_number': 'Number:\s*(.+)\n', |
|
429 |
} |
|
430 |
||
431 |
def __init__(self, domain, text): |
|
432 |
if 'Domain status: available' in text: |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
433 |
raise PywhoisError(text) |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
434 |
else: |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
435 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
436 |
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
437 |
|
| 0 | 438 |
class WhoisMe(WhoisEntry): |
439 |
"""Whois parser for .me domains |
|
440 |
""" |
|
441 |
regex = {
|
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
442 |
'domain_id': 'Domain ID:(.+)', |
| 0 | 443 |
'domain_name': 'Domain Name:(.+)', |
444 |
'creation_date': 'Domain Create Date:(.+)', |
|
445 |
'updated_date': 'Domain Last Updated Date:(.+)', |
|
446 |
'expiration_date': 'Domain Expiration Date:(.+)', |
|
447 |
'transfer_date': 'Last Transferred Date:(.+)', |
|
448 |
'trademark_name': 'Trademark Name:(.+)', |
|
449 |
'trademark_country': 'Trademark Country:(.+)', |
|
450 |
'trademark_number': 'Trademark Number:(.+)', |
|
451 |
'trademark_application_date': 'Date Trademark Applied For:(.+)', |
|
452 |
'trademark_registration_date': 'Date Trademark Registered:(.+)', |
|
453 |
'registrar': 'Sponsoring Registrar:(.+)', |
|
454 |
'created_by': 'Created by:(.+)', |
|
455 |
'updated_by': 'Last Updated by Registrar:(.+)', |
|
456 |
'status': 'Domain Status:(.+)', # list of statuses |
|
457 |
'registrant_id': 'Registrant ID:(.+)', |
|
458 |
'registrant_name': 'Registrant Name:(.+)', |
|
459 |
'registrant_org': 'Registrant Organization:(.+)', |
|
460 |
'registrant_address': 'Registrant Address:(.+)', |
|
461 |
'registrant_address2': 'Registrant Address2:(.+)', |
|
462 |
'registrant_address3': 'Registrant Address3:(.+)', |
|
463 |
'registrant_city': 'Registrant City:(.+)', |
|
464 |
'registrant_state_province': 'Registrant State/Province:(.+)', |
|
465 |
'registrant_country': 'Registrant Country/Economy:(.+)', |
|
466 |
'registrant_postal_code': 'Registrant Postal Code:(.+)', |
|
467 |
'registrant_phone': 'Registrant Phone:(.+)', |
|
468 |
'registrant_phone_ext': 'Registrant Phone Ext\.:(.+)', |
|
469 |
'registrant_fax': 'Registrant FAX:(.+)', |
|
470 |
'registrant_fax_ext': 'Registrant FAX Ext\.:(.+)', |
|
471 |
'registrant_email': 'Registrant E-mail:(.+)', |
|
472 |
'admin_id': 'Admin ID:(.+)', |
|
473 |
'admin_name': 'Admin Name:(.+)', |
|
474 |
'admin_org': 'Admin Organization:(.+)', |
|
475 |
'admin_address': 'Admin Address:(.+)', |
|
476 |
'admin_address2': 'Admin Address2:(.+)', |
|
477 |
'admin_address3': 'Admin Address3:(.+)', |
|
478 |
'admin_city': 'Admin City:(.+)', |
|
479 |
'admin_state_province': 'Admin State/Province:(.+)', |
|
480 |
'admin_country': 'Admin Country/Economy:(.+)', |
|
481 |
'admin_postal_code': 'Admin Postal Code:(.+)', |
|
482 |
'admin_phone': 'Admin Phone:(.+)', |
|
483 |
'admin_phone_ext': 'Admin Phone Ext\.:(.+)', |
|
484 |
'admin_fax': 'Admin FAX:(.+)', |
|
485 |
'admin_fax_ext': 'Admin FAX Ext\.:(.+)', |
|
486 |
'admin_email': 'Admin E-mail:(.+)', |
|
487 |
'tech_id': 'Tech ID:(.+)', |
|
488 |
'tech_name': 'Tech Name:(.+)', |
|
489 |
'tech_org': 'Tech Organization:(.+)', |
|
490 |
'tech_address': 'Tech Address:(.+)', |
|
491 |
'tech_address2': 'Tech Address2:(.+)', |
|
492 |
'tech_address3': 'Tech Address3:(.+)', |
|
493 |
'tech_city': 'Tech City:(.+)', |
|
494 |
'tech_state_province': 'Tech State/Province:(.+)', |
|
495 |
'tech_country': 'Tech Country/Economy:(.+)', |
|
496 |
'tech_postal_code': 'Tech Postal Code:(.+)', |
|
497 |
'tech_phone': 'Tech Phone:(.+)', |
|
498 |
'tech_phone_ext': 'Tech Phone Ext\.:(.+)', |
|
499 |
'tech_fax': 'Tech FAX:(.+)', |
|
500 |
'tech_fax_ext': 'Tech FAX Ext\.:(.+)', |
|
501 |
'tech_email': 'Tech E-mail:(.+)', |
|
502 |
'name_servers': 'Nameservers:(.+)', # list of name servers |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
503 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
504 |
|
| 0 | 505 |
def __init__(self, domain, text): |
506 |
if 'NOT FOUND' in text: |
|
507 |
raise PywhoisError(text) |
|
508 |
else: |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
509 |
WhoisEntry.__init__(self, domain, text, self.regex) |
| 0 | 510 |
|
| 5 | 511 |
|
| 0 | 512 |
class WhoisUk(WhoisEntry): |
513 |
"""Whois parser for .uk domains |
|
514 |
""" |
|
515 |
regex = {
|
|
516 |
'domain_name': 'Domain name:\n\s*(.+)', |
|
517 |
'registrar': 'Registrar:\n\s*(.+)', |
|
518 |
'registrar_url': 'URL:\s*(.+)', |
|
519 |
'status': 'Registration status:\n\s*(.+)', # list of statuses |
|
520 |
'registrant_name': 'Registrant:\n\s*(.+)', |
|
521 |
'creation_date': 'Registered on:\s*(.+)', |
|
| 5 | 522 |
'expiration_date': 'Expiry date:\s*(.+)', |
| 0 | 523 |
'updated_date': 'Last updated:\s*(.+)', |
| 3 | 524 |
'name_servers': 'Name servers:\s*(.+)', |
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
525 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
526 |
|
| 0 | 527 |
def __init__(self, domain, text): |
| 47 | 528 |
if 'No match for ' in text: |
| 0 | 529 |
raise PywhoisError(text) |
530 |
else: |
|
531 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
| 2 | 532 |
|
| 4 | 533 |
|
534 |
class WhoisFr(WhoisEntry): |
|
535 |
"""Whois parser for .fr domains |
|
536 |
""" |
|
537 |
regex = {
|
|
538 |
'domain_name': 'domain:\s*(.+)', |
|
539 |
'registrar': 'registrar:\s*(.+)', |
|
540 |
'creation_date': 'created:\s*(.+)', |
|
541 |
'expiration_date': 'anniversary:\s*(.+)', |
|
542 |
'name_servers': 'nserver:\s*(.+)', # list of name servers |
|
543 |
'status': 'status:\s*(.+)', # list of statuses |
|
544 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
|
545 |
'updated_date': 'last-update:\s*(.+)', |
|
546 |
} |
|
547 |
||
548 |
def __init__(self, domain, text): |
|
| 47 | 549 |
if 'No entries found' in text: |
| 4 | 550 |
raise PywhoisError(text) |
551 |
else: |
|
552 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
553 |
||
554 |
||
| 2 | 555 |
class WhoisFi(WhoisEntry): |
556 |
"""Whois parser for .fi domains |
|
557 |
""" |
|
558 |
regex = {
|
|
559 |
'domain_name': 'domain:\s*([\S]+)', |
|
| 47 | 560 |
'name': 'descr:\s*([\S\ ]+)', |
561 |
'address': 'address:\s*([\S\ ]+)', |
|
562 |
'phone': 'phone:\s*([\S\ ]+)', |
|
| 2 | 563 |
'status': 'status:\s*([\S]+)', # list of statuses |
564 |
'creation_date': 'created:\s*([\S]+)', |
|
565 |
'updated_date': 'modified:\s*([\S]+)', |
|
566 |
'expiration_date': 'expires:\s*([\S]+)', |
|
| 13 | 567 |
'name_servers': 'nserver:\s*([\S]+) \[\S+\]', # list of name servers |
568 |
'name_server_statuses': 'nserver:\s*([\S]+) \[(\S+)\]', # list of name servers and statuses |
|
| 28 | 569 |
'dnssec': 'dnssec:\s*([\S]+)', |
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
570 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
571 |
|
| 2 | 572 |
def __init__(self, domain, text): |
| 13 | 573 |
if 'Domain not ' in text: |
| 2 | 574 |
raise PywhoisError(text) |
575 |
else: |
|
576 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
| 5 | 577 |
|
578 |
||
579 |
class WhoisJp(WhoisEntry): |
|
580 |
"""Whois parser for .jp domains |
|
581 |
""" |
|
582 |
regex = {
|
|
583 |
'domain_name': 'a\. \[Domain Name\]\s*(.+)', |
|
584 |
'registrant_org': 'g\. \[Organization\](.+)', |
|
585 |
'creation_date': r'\[Registered Date\]\s*(.+)', |
|
586 |
'name_servers': 'p\. \[Name Server\]\s*(.+)', # list of name servers |
|
587 |
'updated_date': '\[Last Update\]\s?(.+)', |
|
588 |
'status': '\[State\]\s*(.+)', # list of statuses |
|
589 |
} |
|
590 |
||
591 |
def __init__(self, domain, text): |
|
| 47 | 592 |
if 'No match!!' in text: |
| 5 | 593 |
raise PywhoisError(text) |
594 |
else: |
|
595 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
| 15 | 596 |
|
| 17 | 597 |
|
598 |
class WhoisAU(WhoisEntry): |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
599 |
"""Whois parser for .au domains |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
600 |
""" |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
601 |
regex = {
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
602 |
'domain_name': 'Domain Name:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
603 |
'last_modified': 'Last Modified:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
604 |
'registrar': 'Registrar Name:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
605 |
'status': 'Status:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
606 |
'registrant_name': 'Registrant:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
607 |
'name_servers': 'Name Server:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
608 |
} |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
609 |
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
610 |
def __init__(self, domain, text): |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
611 |
if text.strip() == 'No Data Found': |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
612 |
raise PywhoisError(text) |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
613 |
else: |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
614 |
WhoisEntry.__init__(self, domain, text, self.regex) |
| 17 | 615 |
|
616 |
||
| 20 | 617 |
class WhoisEu(WhoisEntry): |
618 |
"""Whois parser for .eu domains |
|
619 |
""" |
|
620 |
regex = {
|
|
621 |
'domain_name': r'Domain:\s*([^\n\r]+)', |
|
622 |
'tech_name': r'Technical:\s*Name:\s*([^\n\r]+)', |
|
623 |
'tech_org': r'Technical:\s*Name:\s*[^\n\r]+\s*Organisation:\s*([^\n\r]+)', |
|
624 |
'tech_phone': r'Technical:\s*Name:\s*[^\n\r]+\s*Organisation:\s*[^\n\r]+\s*Language:\s*[^\n\r]+\s*Phone:\s*([^\n\r]+)', |
|
625 |
'tech_fax': r'Technical:\s*Name:\s*[^\n\r]+\s*Organisation:\s*[^\n\r]+\s*Language:\s*[^\n\r]+\s*Phone:\s*[^\n\r]+\s*Fax:\s*([^\n\r]+)', |
|
626 |
'tech_email': r'Technical:\s*Name:\s*[^\n\r]+\s*Organisation:\s*[^\n\r]+\s*Language:\s*[^\n\r]+\s*Phone:\s*[^\n\r]+\s*Fax:\s*[^\n\r]+\s*Email:\s*([^\n\r]+)', |
|
627 |
'registrar': r'Registrar:\s*Name:\s*([^\n\r]+)', |
|
| 50 | 628 |
'name_servers': r'Name servers:\s*([^\n\r]+)\s*([^\n\r]*)', # list of name servers |
| 20 | 629 |
} |
630 |
||
631 |
def __init__(self, domain, text): |
|
632 |
if text.strip() == 'Status: AVAILABLE': |
|
633 |
raise PywhoisError(text) |
|
634 |
else: |
|
635 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
636 |
||
637 |
||
| 15 | 638 |
class WhoisBr(WhoisEntry): |
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
639 |
"""Whois parser for .br domains |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
640 |
""" |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
641 |
regex = {
|
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
642 |
'domain': 'domain:\s*(.+)\n', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
643 |
'owner': 'owner:\s*([\S ]+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
644 |
'ownerid': 'ownerid:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
645 |
'country': 'country:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
646 |
'owner_c': 'owner-c:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
647 |
'admin_c': 'admin-c:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
648 |
'tech_c': 'tech-c:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
649 |
'billing_c': 'billing-c:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
650 |
'nserver': 'nserver:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
651 |
'nsstat': 'nsstat:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
652 |
'nslastaa': 'nslastaa:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
653 |
'saci': 'saci:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
654 |
'created': 'created:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
655 |
'expires': 'expires:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
656 |
'changed': 'changed:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
657 |
'status': 'status:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
658 |
'nic_hdl_br': 'nic-hdl-br:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
659 |
'person': 'person:\s*([\S ]+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
660 |
'email': 'e-mail:\s*(.+)', |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
661 |
} |
| 15 | 662 |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
663 |
def __init__(self, domain, text): |
| 15 | 664 |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
665 |
if 'Not found:' in text: |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
666 |
raise PywhoisError(text) |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
667 |
else: |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
668 |
WhoisEntry.__init__(self, domain, text, self.regex) |
| 15 | 669 |
|
| 19 | 670 |
|
671 |
class WhoisKr(WhoisEntry): |
|
672 |
"""Whois parser for .kr domains |
|
673 |
""" |
|
674 |
regex = {
|
|
675 |
'domain_name': 'Domain Name\s*:\s*(.+)', |
|
676 |
'registrant_org': 'Registrant\s*:\s*(.+)', |
|
677 |
'registrant_address': 'Registrant Address\s*:\s*(.+)', |
|
678 |
'registrant_zip': 'Registrant Zip Code\s*:\s*(.+)', |
|
679 |
'admin_name': 'Administrative Contact\(AC\)\s*:\s*(.+)', |
|
680 |
'admin_email': 'AC E-Mail\s*:\s*(.+)', |
|
681 |
'admin_phone': 'AC Phone Number\s*:\s*(.+)', |
|
682 |
'creation_date': 'Registered Date\s*:\s*(.+)', |
|
683 |
'updated_date': 'Last updated Date\s*:\s*(.+)', |
|
684 |
'expiration_date': 'Expiration Date\s*:\s*(.+)', |
|
685 |
'registrar': 'Authorized Agency\s*:\s*(.+)', |
|
686 |
'name_servers': 'Host Name\s*:\s*(.+)', # list of name servers |
|
687 |
} |
|
688 |
||
689 |
def __init__(self, domain, text): |
|
| 47 | 690 |
if text.endswith(' no match'):
|
| 19 | 691 |
raise PywhoisError(text) |
692 |
else: |
|
693 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
694 |
||
695 |
||
| 21 | 696 |
class WhoisPt(WhoisEntry): |
697 |
"""Whois parser for .pt domains |
|
698 |
""" |
|
699 |
regex = {
|
|
700 |
'domain_name': 'domain name:\s*(.+)', |
|
701 |
'creation_date': 'creation date \(dd\/mm\/yyyy\):\s*(.+)', |
|
702 |
'expiration_date': 'expiration date \(dd\/mm\/yyyy\):\s*(.+)', |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
703 |
'name_servers': '\tNS\t(.+).', # list of name servers |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
704 |
'status': 'status:\s*(.+)', # list of statuses |
|
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
705 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
| 21 | 706 |
} |
707 |
||
708 |
def __init__(self, domain, text): |
|
709 |
if text.strip() == 'No entries found': |
|
710 |
raise PywhoisError(text) |
|
711 |
else: |
|
712 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
|
26
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
713 |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
714 |
|
|
26
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
715 |
class WhoisBg(WhoisEntry): |
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
716 |
"""Whois parser for .bg domains""" |
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
717 |
|
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
718 |
regex = {
|
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
719 |
'expiration_date': 'expires at:\s*(.+)', |
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
720 |
} |
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
721 |
|
|
43
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
722 |
dayfirst = True |
|
f7bf8d6f0547
[#59] Add support for dateutil.parser dayfirst and yearfirst arguments
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
42
diff
changeset
|
723 |
|
|
26
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
724 |
def __init__(self, domain, text): |
| 47 | 725 |
if 'does not exist in database!' in text: |
|
26
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
726 |
raise PywhoisError(text) |
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
727 |
else: |
|
e0b929723473
Add expiry_date regex for .bg domains
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
24
diff
changeset
|
728 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
37
8ad334b5363b
Add .рф TLD expiration_date regex
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
30
diff
changeset
|
729 |
|
|
40
9573d5bc9ad5
Stylistic improvements on parser.py
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
39
diff
changeset
|
730 |
|
|
53
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
731 |
class WhoisRf(WhoisRu): |
|
37
8ad334b5363b
Add .рф TLD expiration_date regex
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
30
diff
changeset
|
732 |
|
|
53
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
733 |
"""Whois parser for .rf domains |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
734 |
""" |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
735 |
def __init__(self): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
736 |
super(WhoisRf, self).__init__() |
|
44
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
737 |
|
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
738 |
|
| 47 | 739 |
class WhoisDe(WhoisEntry): |
740 |
"""Whois parser for .de domains""" |
|
741 |
||
742 |
regex = {
|
|
743 |
'name': 'name:\s*(.+)', |
|
744 |
'org': 'Organisation:\s*(.+)', |
|
745 |
'address': 'Address:\s*(.+)', |
|
746 |
'zipcode': 'PostalCode:\s*(.+)', |
|
747 |
'city': 'City:\s*(.+)', |
|
748 |
'country_code': 'CountryCode:\s*(.+)', |
|
749 |
'phone': 'Phone:\s*(.+)', |
|
750 |
'fax': 'Fax:\s*(.+)' |
|
751 |
} |
|
752 |
||
753 |
def __init__(self, domain, text): |
|
754 |
if 'Status: free' in text: |
|
755 |
raise PywhoisError(text) |
|
756 |
else: |
|
757 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
758 |
||
759 |
||
760 |
class WhoisBe(WhoisEntry): |
|
761 |
"""Whois parser for .be domains""" |
|
762 |
||
763 |
regex = {
|
|
764 |
'name': 'Name:\s*(.+)', |
|
765 |
'org': 'Organisation:\s*(.+)', |
|
766 |
'phone': 'Phone:\s*(.+)', |
|
767 |
'fax': 'Fax:\s*(.+)', |
|
768 |
'email': 'Email:\s*(.+)', |
|
769 |
} |
|
770 |
||
771 |
def __init__(self, domain, text): |
|
772 |
if 'Status: AVAILABLE' in text: |
|
773 |
raise PywhoisError(text) |
|
774 |
else: |
|
775 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
776 |
||
777 |
||
778 |
||
|
44
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
779 |
class WhoisInfo(WhoisEntry): |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
780 |
"""Whois parser for .info domains |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
781 |
""" |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
782 |
regex = {
|
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
783 |
'domain_name': 'Domain Name:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
784 |
'registrar': 'Registrar:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
785 |
'whois_server': 'Whois Server:\s?(.+)', # empty usually |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
786 |
'referral_url': 'Referral URL:\s?(.+)', # http url of whois_server: empty usually |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
787 |
'updated_date': 'Updated Date:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
788 |
'creation_date': 'Creation Date:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
789 |
'expiration_date': 'Registry Expiry Date:\s?(.+)', |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
790 |
'name_servers': 'Name Server:\s?(.+)', # list of name servers |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
791 |
'status': 'Status:\s?(.+)', # list of statuses |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
792 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
| 47 | 793 |
'name': 'Registrant Name:\s*(.+)', |
794 |
'org': 'Registrant Organization:\s*(.+)', |
|
795 |
'address': 'Registrant Street:\s*(.+)', |
|
796 |
'city': 'Registrant City:\s*(.+)', |
|
797 |
'state': 'Registrant State/Province:\s*(.+)', |
|
798 |
'zipcode': 'Registrant Postal Code:\s*(.+)', |
|
799 |
'country': 'Registrant Country:\s*(.+)', |
|
|
44
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
800 |
} |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
801 |
|
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
802 |
def __init__(self, domain, text): |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
803 |
if text.strip() == 'NOT FOUND': |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
804 |
raise PywhoisError(text) |
|
5cd71f1dc42b
committed support for new .org and .info format #60
Richard Penman
parents:
43
diff
changeset
|
805 |
else: |
|
46
b3862a45fdad
Always import datetime no matter if dateutil is present
Evgeni Kunev <evgeni.kunev@gmail.com>
parents:
44
diff
changeset
|
806 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
53
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
807 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
808 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
809 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
810 |
class WhoisSu(WhoisRu): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
811 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
812 |
"""Whois parser for .su domains |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
813 |
""" |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
814 |
def __init__(self): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
815 |
super(WhoisSu, self).__init__() |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
816 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
817 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
818 |
class WhoisClub(WhoisEntry): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
819 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
820 |
"""Whois parser for .us domains |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
821 |
""" |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
822 |
regex = {
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
823 |
'domain_name': 'Domain Name:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
824 |
'domain__id': 'Domain ID:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
825 |
'registrar': 'Sponsoring Registrar:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
826 |
'registrar_id': 'Sponsoring Registrar IANA ID:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
827 |
'registrar_url': 'Registrar URL \(registration services\):\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
828 |
# list of statuses |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
829 |
'status': 'Domain Status:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
830 |
'registrant_id': 'Registrant ID:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
831 |
'registrant_name': 'Registrant Name:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
832 |
'registrant_address1': 'Registrant Address1:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
833 |
'registrant_address2': 'Registrant Address2:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
834 |
'registrant_city': 'Registrant City:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
835 |
'registrant_state_province': 'Registrant State/Province:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
836 |
'registrant_postal_code': 'Registrant Postal Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
837 |
'registrant_country': 'Registrant Country:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
838 |
'registrant_country_code': 'Registrant Country Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
839 |
'registrant_phone_number': 'Registrant Phone Number:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
840 |
'registrant_email': 'Registrant Email:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
841 |
'registrant_application_purpose': 'Registrant Application Purpose:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
842 |
'registrant_nexus_category': 'Registrant Nexus Category:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
843 |
'admin_id': 'Administrative Contact ID:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
844 |
'admin_name': 'Administrative Contact Name:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
845 |
'admin_address1': 'Administrative Contact Address1:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
846 |
'admin_address2': 'Administrative Contact Address2:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
847 |
'admin_city': 'Administrative Contact City:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
848 |
'admin_state_province': 'Administrative Contact State/Province:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
849 |
'admin_postal_code': 'Administrative Contact Postal Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
850 |
'admin_country': 'Administrative Contact Country:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
851 |
'admin_country_code': 'Administrative Contact Country Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
852 |
'admin_phone_number': 'Administrative Contact Phone Number:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
853 |
'admin_email': 'Administrative Contact Email:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
854 |
'admin_application_purpose': 'Administrative Application Purpose:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
855 |
'admin_nexus_category': 'Administrative Nexus Category:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
856 |
'billing_id': 'Billing Contact ID:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
857 |
'billing_name': 'Billing Contact Name:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
858 |
'billing_address1': 'Billing Contact Address1:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
859 |
'billing_address2': 'Billing Contact Address2:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
860 |
'billing_city': 'Billing Contact City:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
861 |
'billing_state_province': 'Billing Contact State/Province:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
862 |
'billing_postal_code': 'Billing Contact Postal Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
863 |
'billing_country': 'Billing Contact Country:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
864 |
'billing_country_code': 'Billing Contact Country Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
865 |
'billing_phone_number': 'Billing Contact Phone Number:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
866 |
'billing_email': 'Billing Contact Email:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
867 |
'billing_application_purpose': 'Billing Application Purpose:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
868 |
'billing_nexus_category': 'Billing Nexus Category:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
869 |
'tech_id': 'Technical Contact ID:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
870 |
'tech_name': 'Technical Contact Name:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
871 |
'tech_address1': 'Technical Contact Address1:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
872 |
'tech_address2': 'Technical Contact Address2:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
873 |
'tech_city': 'Technical Contact City:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
874 |
'tech_state_province': 'Technical Contact State/Province:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
875 |
'tech_postal_code': 'Technical Contact Postal Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
876 |
'tech_country': 'Technical Contact Country:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
877 |
'tech_country_code': 'Technical Contact Country Code:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
878 |
'tech_phone_number': 'Technical Contact Phone Number:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
879 |
'tech_email': 'Technical Contact Email:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
880 |
'tech_application_purpose': 'Technical Application Purpose:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
881 |
'tech_nexus_category': 'Technical Nexus Category:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
882 |
# list of name servers |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
883 |
'name_servers': 'Name Server:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
884 |
'created_by_registrar': 'Created by Registrar:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
885 |
'last_updated_by_registrar': 'Last Updated by Registrar:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
886 |
'creation_date': 'Domain Registration Date:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
887 |
'expiration_date': 'Domain Expiration Date:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
888 |
'updated_date': 'Domain Last Updated Date:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
889 |
} |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
890 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
891 |
def __init__(self, domain, text): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
892 |
if 'Not found:' in text: |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
893 |
raise PywhoisError(text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
894 |
else: |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
895 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
896 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
897 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
898 |
class WhoisIo(WhoisEntry): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
899 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
900 |
"""Whois parser for .io domains""" |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
901 |
regex = {
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
902 |
'status': 'Status\s*:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
903 |
'name_servers': 'NS \d?\s*:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
904 |
'owner': 'Owner\s*:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
905 |
'expiration_date': 'Expiry\s*:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
906 |
'domain_name': 'Domain\s*:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
907 |
'registrar': r'Check for \'[\w\.]*\' --- (.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
908 |
} |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
909 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
910 |
def __init__(self, domain, text): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
911 |
if 'is available for purchase' in text: |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
912 |
raise PywhoisError(text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
913 |
else: |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
914 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
915 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
916 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
917 |
class WhoisBiz(WhoisEntry): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
918 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
919 |
"""Whois parser for .biz domains""" |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
920 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
921 |
def __init__(self, domain, text): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
922 |
super(WhoisUs, self).__init__(domain, text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
923 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
924 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
925 |
class WhoisMobi(WhoisMe): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
926 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
927 |
def __init__(self, domain, text): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
928 |
super(WhoisMobi, self).__init__(domain, text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
929 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
930 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
931 |
class WhoisKg(WhoisEntry): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
932 |
regex = {
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
933 |
'domain_name': 'Domain\s*([\w]+\.[\w]{2,5})',
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
934 |
'registrar': 'Domain support: \s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
935 |
'registrant_name': 'Name:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
936 |
'registrant_address1': 'Address:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
937 |
'registrant_phone_number': 'phone:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
938 |
'registrant_email': 'Email:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
939 |
# # list of name servers |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
940 |
'name_servers': 'Name servers in the listed order:\s*([\d\w\.\s]+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
941 |
# 'name_servers': r'([\w]+\.[\w]+\.[\w]{2,5}\s*\d{1,3}\.\d]{1,3}\.[\d]{1-3}\.[\d]{1-3})',
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
942 |
'creation_date': 'Record created:\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
943 |
'expiration_date': 'Record expires on \s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
944 |
'updated_date': 'Record last updated on\s*(.+)', |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
945 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
946 |
} |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
947 |
def __init__(self, domain, text): |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
948 |
if 'Data not found. This domain is available for registration' in text: |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
949 |
raise PywhoisError(text) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
950 |
else: |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
951 |
WhoisEntry.__init__(self, domain, text, self.regex) |
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
952 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
953 |
|
|
e2eaf1755fce
[#71] missing .mobi, .io, .kg, .su, .biz
Amy Woodehy <amywoodehy@gmail.com>
parents:
50
diff
changeset
|
954 |