|
0
|
1 |
# parser.py - Module for parsing whois response data
|
|
|
2 |
# Copyright (c) 2008 Andrey Petrov
|
|
|
3 |
#
|
|
|
4 |
# This module is part of pywhois and is released under
|
|
|
5 |
# the MIT license: http://www.opensource.org/licenses/mit-license.php
|
|
|
6 |
|
|
|
7 |
import re
|
|
2
|
8 |
from datetime import datetime
|
|
0
|
9 |
|
|
|
10 |
|
|
|
11 |
class PywhoisError(Exception):
|
|
|
12 |
pass
|
|
|
13 |
|
|
|
14 |
|
|
5
|
15 |
def cast_date(s):
|
|
|
16 |
"""Convert any date string found in WHOIS to a datetime object.
|
|
0
|
17 |
"""
|
|
|
18 |
known_formats = [
|
|
|
19 |
'%d-%b-%Y', # 02-jan-2000
|
|
|
20 |
'%Y-%m-%d', # 2000-01-02
|
|
13
|
21 |
'%d.%m.%Y', # 2.1.2000
|
|
5
|
22 |
'%Y.%m.%d', # 2000.01.02
|
|
|
23 |
'%Y/%m/%d', # 2000/01/02
|
|
0
|
24 |
'%d-%b-%Y %H:%M:%S %Z', # 24-Jul-2009 13:20:03 UTC
|
|
|
25 |
'%a %b %d %H:%M:%S %Z %Y', # Tue Jun 21 23:59:59 GMT 2011
|
|
|
26 |
'%Y-%m-%dT%H:%M:%SZ', # 2007-01-26T19:10:31Z
|
|
16
|
27 |
'%Y-%m-%d %H:%M:%SZ', # 2000-08-22 18:55:20Z
|
|
17
|
28 |
'%Y-%m-%d %H:%M:%S', # 2000-08-22 18:55:20
|
|
16
|
29 |
'%d %b %Y %H:%M:%S', # 08 Apr 2013 05:44:00
|
|
0
|
30 |
]
|
|
|
31 |
|
|
5
|
32 |
for known_format in known_formats:
|
|
0
|
33 |
try:
|
|
17
|
34 |
s = datetime.strptime(s.strip(), known_format)
|
|
|
35 |
break
|
|
12
|
36 |
except ValueError as e:
|
|
0
|
37 |
pass # Wrong format, keep trying
|
|
5
|
38 |
return s
|
|
0
|
39 |
|
|
|
40 |
|
|
|
41 |
class WhoisEntry(object):
|
|
|
42 |
"""Base class for parsing a Whois entries.
|
|
|
43 |
"""
|
|
|
44 |
# regular expressions to extract domain data from whois profile
|
|
|
45 |
# child classes will override this
|
|
|
46 |
_regex = {
|
|
|
47 |
'domain_name': 'Domain Name:\s?(.+)',
|
|
|
48 |
'registrar': 'Registrar:\s?(.+)',
|
|
|
49 |
'whois_server': 'Whois Server:\s?(.+)',
|
|
|
50 |
'referral_url': 'Referral URL:\s?(.+)', # http url of whois_server
|
|
|
51 |
'updated_date': 'Updated Date:\s?(.+)',
|
|
|
52 |
'creation_date': 'Creation Date:\s?(.+)',
|
|
|
53 |
'expiration_date': 'Expiration Date:\s?(.+)',
|
|
|
54 |
'name_servers': 'Name Server:\s?(.+)', # list of name servers
|
|
|
55 |
'status': 'Status:\s?(.+)', # list of statuses
|
|
|
56 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
def __init__(self, domain, text, regex=None):
|
|
|
60 |
self.domain = domain
|
|
|
61 |
self.text = text
|
|
|
62 |
if regex is not None:
|
|
|
63 |
self._regex = regex
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
def __getattr__(self, attr):
|
|
|
67 |
"""The first time an attribute is called it will be calculated here.
|
|
|
68 |
The attribute is then set to be accessed directly by subsequent calls.
|
|
|
69 |
"""
|
|
|
70 |
whois_regex = self._regex.get(attr)
|
|
|
71 |
if whois_regex:
|
|
14
|
72 |
values = []
|
|
|
73 |
for value in re.findall(whois_regex, self.text, re.IGNORECASE):
|
|
|
74 |
if isinstance(value, basestring):
|
|
|
75 |
# try casting to date format
|
|
|
76 |
value = cast_date(value.strip())
|
|
16
|
77 |
if value not in values:
|
|
|
78 |
# avoid duplicates
|
|
|
79 |
values.append(value)
|
|
5
|
80 |
if len(values) == 1:
|
|
|
81 |
values = values[0]
|
|
16
|
82 |
|
|
5
|
83 |
setattr(self, attr, values)
|
|
0
|
84 |
return getattr(self, attr)
|
|
|
85 |
else:
|
|
|
86 |
raise KeyError('Unknown attribute: %s' % attr)
|
|
|
87 |
|
|
|
88 |
def __str__(self):
|
|
|
89 |
"""Print all whois properties of domain
|
|
|
90 |
"""
|
|
|
91 |
return '\n'.join('%s: %s' % (attr, str(getattr(self, attr))) for attr in self.attrs())
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
def attrs(self):
|
|
|
95 |
"""Return list of attributes that can be extracted for this domain
|
|
|
96 |
"""
|
|
|
97 |
return sorted(self._regex.keys())
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
@staticmethod
|
|
|
101 |
def load(domain, text):
|
|
|
102 |
"""Given whois output in ``text``, return an instance of ``WhoisEntry`` that represents its parsed contents.
|
|
|
103 |
"""
|
|
|
104 |
if text.strip() == 'No whois server is known for this kind of object.':
|
|
|
105 |
raise PywhoisError(text)
|
|
|
106 |
|
|
10
|
107 |
if domain.endswith('.com'):
|
|
0
|
108 |
return WhoisCom(domain, text)
|
|
10
|
109 |
elif domain.endswith('.net'):
|
|
0
|
110 |
return WhoisNet(domain, text)
|
|
10
|
111 |
elif domain.endswith('.org'):
|
|
0
|
112 |
return WhoisOrg(domain, text)
|
|
10
|
113 |
elif domain.endswith('.name'):
|
|
0
|
114 |
return WhoisName(domain, text)
|
|
10
|
115 |
elif domain.endswith('.me'):
|
|
|
116 |
return WhoisMe(domain, text)
|
|
17
|
117 |
elif domain.endswith('.au'):
|
|
|
118 |
return WhoisAU(domain, text)
|
|
10
|
119 |
elif domain.endswith('.ru'):
|
|
|
120 |
return WhoisRu(domain, text)
|
|
|
121 |
elif domain.endswith('.us'):
|
|
0
|
122 |
return WhoisUs(domain, text)
|
|
10
|
123 |
elif domain.endswith('.uk'):
|
|
0
|
124 |
return WhoisUk(domain, text)
|
|
10
|
125 |
elif domain.endswith('.fr'):
|
|
4
|
126 |
return WhoisFr(domain, text)
|
|
10
|
127 |
elif domain.endswith('.fi'):
|
|
2
|
128 |
return WhoisFi(domain, text)
|
|
10
|
129 |
elif domain.endswith('.jp'):
|
|
5
|
130 |
return WhoisJp(domain, text)
|
|
11
|
131 |
elif domain.endswith('.pl'):
|
|
|
132 |
return WhoisPl(domain, text)
|
|
15
|
133 |
elif domain.endswith('.br'):
|
|
|
134 |
return WhoisBr(domain,text)
|
|
0
|
135 |
else:
|
|
|
136 |
return WhoisEntry(domain, text)
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
class WhoisCom(WhoisEntry):
|
|
|
141 |
"""Whois parser for .com domains
|
|
|
142 |
"""
|
|
|
143 |
def __init__(self, domain, text):
|
|
|
144 |
if 'No match for "' in text:
|
|
|
145 |
raise PywhoisError(text)
|
|
|
146 |
else:
|
|
|
147 |
WhoisEntry.__init__(self, domain, text)
|
|
|
148 |
|
|
4
|
149 |
|
|
0
|
150 |
class WhoisNet(WhoisEntry):
|
|
|
151 |
"""Whois parser for .net domains
|
|
|
152 |
"""
|
|
|
153 |
def __init__(self, domain, text):
|
|
|
154 |
if 'No match for "' in text:
|
|
|
155 |
raise PywhoisError(text)
|
|
|
156 |
else:
|
|
|
157 |
WhoisEntry.__init__(self, domain, text)
|
|
|
158 |
|
|
4
|
159 |
|
|
0
|
160 |
class WhoisOrg(WhoisEntry):
|
|
|
161 |
"""Whois parser for .org domains
|
|
|
162 |
"""
|
|
|
163 |
def __init__(self, domain, text):
|
|
|
164 |
if text.strip() == 'NOT FOUND':
|
|
|
165 |
raise PywhoisError(text)
|
|
|
166 |
else:
|
|
|
167 |
WhoisEntry.__init__(self, domain, text)
|
|
|
168 |
|
|
4
|
169 |
|
|
0
|
170 |
class WhoisRu(WhoisEntry):
|
|
|
171 |
"""Whois parser for .ru domains
|
|
|
172 |
"""
|
|
|
173 |
regex = {
|
|
|
174 |
'domain_name': 'domain:\s*(.+)',
|
|
|
175 |
'registrar': 'registrar:\s*(.+)',
|
|
|
176 |
'creation_date': 'created:\s*(.+)',
|
|
|
177 |
'expiration_date': 'paid-till:\s*(.+)',
|
|
|
178 |
'name_servers': 'nserver:\s*(.+)', # list of name servers
|
|
|
179 |
'status': 'state:\s*(.+)', # list of statuses
|
|
|
180 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
def __init__(self, domain, text):
|
|
|
184 |
if text.strip() == 'No entries found':
|
|
|
185 |
raise PywhoisError(text)
|
|
|
186 |
else:
|
|
|
187 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
|
188 |
|
|
4
|
189 |
|
|
0
|
190 |
class WhoisName(WhoisEntry):
|
|
|
191 |
"""Whois parser for .name domains
|
|
|
192 |
"""
|
|
|
193 |
regex = {
|
|
|
194 |
'domain_name_id': 'Domain Name ID:\s*(.+)',
|
|
|
195 |
'domain_name': 'Domain Name:\s*(.+)',
|
|
|
196 |
'registrar_id': 'Sponsoring Registrar ID:\s*(.+)',
|
|
|
197 |
'registrar': 'Sponsoring Registrar:\s*(.+)',
|
|
|
198 |
'registrant_id': 'Registrant ID:\s*(.+)',
|
|
|
199 |
'admin_id': 'Admin ID:\s*(.+)',
|
|
|
200 |
'technical_id': 'Tech ID:\s*(.+)',
|
|
|
201 |
'billing_id': 'Billing ID:\s*(.+)',
|
|
|
202 |
'creation_date': 'Created On:\s*(.+)',
|
|
|
203 |
'expiration_date': 'Expires On:\s*(.+)',
|
|
|
204 |
'updated_date': 'Updated On:\s*(.+)',
|
|
|
205 |
'name_server_ids': 'Name Server ID:\s*(.+)', # list of name server ids
|
|
|
206 |
'name_servers': 'Name Server:\s*(.+)', # list of name servers
|
|
|
207 |
'status': 'Domain Status:\s*(.+)', # list of statuses
|
|
|
208 |
}
|
|
|
209 |
def __init__(self, domain, text):
|
|
|
210 |
if 'No match.' in text:
|
|
|
211 |
raise PywhoisError(text)
|
|
|
212 |
else:
|
|
|
213 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
4
|
214 |
|
|
|
215 |
|
|
0
|
216 |
class WhoisUs(WhoisEntry):
|
|
|
217 |
"""Whois parser for .us domains
|
|
|
218 |
"""
|
|
|
219 |
regex = {
|
|
|
220 |
'domain_name': 'Domain Name:\s*(.+)',
|
|
|
221 |
'domain__id': 'Domain ID:\s*(.+)',
|
|
|
222 |
'registrar': 'Sponsoring Registrar:\s*(.+)',
|
|
|
223 |
'registrar_id': 'Sponsoring Registrar IANA ID:\s*(.+)',
|
|
|
224 |
'registrar_url': 'Registrar URL \(registration services\):\s*(.+)',
|
|
|
225 |
'status': 'Domain Status:\s*(.+)', # list of statuses
|
|
|
226 |
'registrant_id': 'Registrant ID:\s*(.+)',
|
|
|
227 |
'registrant_name': 'Registrant Name:\s*(.+)',
|
|
|
228 |
'registrant_address1': 'Registrant Address1:\s*(.+)',
|
|
|
229 |
'registrant_address2': 'Registrant Address2:\s*(.+)',
|
|
|
230 |
'registrant_city': 'Registrant City:\s*(.+)',
|
|
|
231 |
'registrant_state_province': 'Registrant State/Province:\s*(.+)',
|
|
|
232 |
'registrant_postal_code': 'Registrant Postal Code:\s*(.+)',
|
|
|
233 |
'registrant_country': 'Registrant Country:\s*(.+)',
|
|
|
234 |
'registrant_country_code': 'Registrant Country Code:\s*(.+)',
|
|
|
235 |
'registrant_phone_number': 'Registrant Phone Number:\s*(.+)',
|
|
|
236 |
'registrant_email': 'Registrant Email:\s*(.+)',
|
|
|
237 |
'registrant_application_purpose': 'Registrant Application Purpose:\s*(.+)',
|
|
|
238 |
'registrant_nexus_category': 'Registrant Nexus Category:\s*(.+)',
|
|
|
239 |
'admin_id': 'Administrative Contact ID:\s*(.+)',
|
|
|
240 |
'admin_name': 'Administrative Contact Name:\s*(.+)',
|
|
|
241 |
'admin_address1': 'Administrative Contact Address1:\s*(.+)',
|
|
|
242 |
'admin_address2': 'Administrative Contact Address2:\s*(.+)',
|
|
|
243 |
'admin_city': 'Administrative Contact City:\s*(.+)',
|
|
|
244 |
'admin_state_province': 'Administrative Contact State/Province:\s*(.+)',
|
|
|
245 |
'admin_postal_code': 'Administrative Contact Postal Code:\s*(.+)',
|
|
|
246 |
'admin_country': 'Administrative Contact Country:\s*(.+)',
|
|
|
247 |
'admin_country_code': 'Administrative Contact Country Code:\s*(.+)',
|
|
|
248 |
'admin_phone_number': 'Administrative Contact Phone Number:\s*(.+)',
|
|
|
249 |
'admin_email': 'Administrative Contact Email:\s*(.+)',
|
|
|
250 |
'admin_application_purpose': 'Administrative Application Purpose:\s*(.+)',
|
|
|
251 |
'admin_nexus_category': 'Administrative Nexus Category:\s*(.+)',
|
|
|
252 |
'billing_id': 'Billing Contact ID:\s*(.+)',
|
|
|
253 |
'billing_name': 'Billing Contact Name:\s*(.+)',
|
|
|
254 |
'billing_address1': 'Billing Contact Address1:\s*(.+)',
|
|
|
255 |
'billing_address2': 'Billing Contact Address2:\s*(.+)',
|
|
|
256 |
'billing_city': 'Billing Contact City:\s*(.+)',
|
|
|
257 |
'billing_state_province': 'Billing Contact State/Province:\s*(.+)',
|
|
|
258 |
'billing_postal_code': 'Billing Contact Postal Code:\s*(.+)',
|
|
|
259 |
'billing_country': 'Billing Contact Country:\s*(.+)',
|
|
|
260 |
'billing_country_code': 'Billing Contact Country Code:\s*(.+)',
|
|
|
261 |
'billing_phone_number': 'Billing Contact Phone Number:\s*(.+)',
|
|
|
262 |
'billing_email': 'Billing Contact Email:\s*(.+)',
|
|
|
263 |
'billing_application_purpose': 'Billing Application Purpose:\s*(.+)',
|
|
|
264 |
'billing_nexus_category': 'Billing Nexus Category:\s*(.+)',
|
|
|
265 |
'tech_id': 'Technical Contact ID:\s*(.+)',
|
|
|
266 |
'tech_name': 'Technical Contact Name:\s*(.+)',
|
|
|
267 |
'tech_address1': 'Technical Contact Address1:\s*(.+)',
|
|
|
268 |
'tech_address2': 'Technical Contact Address2:\s*(.+)',
|
|
|
269 |
'tech_city': 'Technical Contact City:\s*(.+)',
|
|
|
270 |
'tech_state_province': 'Technical Contact State/Province:\s*(.+)',
|
|
|
271 |
'tech_postal_code': 'Technical Contact Postal Code:\s*(.+)',
|
|
|
272 |
'tech_country': 'Technical Contact Country:\s*(.+)',
|
|
|
273 |
'tech_country_code': 'Technical Contact Country Code:\s*(.+)',
|
|
|
274 |
'tech_phone_number': 'Technical Contact Phone Number:\s*(.+)',
|
|
|
275 |
'tech_email': 'Technical Contact Email:\s*(.+)',
|
|
|
276 |
'tech_application_purpose': 'Technical Application Purpose:\s*(.+)',
|
|
|
277 |
'tech_nexus_category': 'Technical Nexus Category:\s*(.+)',
|
|
|
278 |
'name_servers': 'Name Server:\s*(.+)', # list of name servers
|
|
|
279 |
'created_by_registrar': 'Created by Registrar:\s*(.+)',
|
|
|
280 |
'last_updated_by_registrar': 'Last Updated by Registrar:\s*(.+)',
|
|
|
281 |
'creation_date': 'Domain Registration Date:\s*(.+)',
|
|
|
282 |
'expiration_date': 'Domain Expiration Date:\s*(.+)',
|
|
|
283 |
'updated_date': 'Domain Last Updated Date:\s*(.+)',
|
|
|
284 |
}
|
|
|
285 |
def __init__(self, domain, text):
|
|
|
286 |
if 'Not found:' in text:
|
|
|
287 |
raise PywhoisError(text)
|
|
|
288 |
else:
|
|
|
289 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
11
|
290 |
|
|
|
291 |
|
|
|
292 |
class WhoisPl(WhoisEntry):
|
|
|
293 |
"""Whois parser for .uk domains
|
|
|
294 |
"""
|
|
|
295 |
regex = {
|
|
|
296 |
'domain_name': 'DOMAIN NAME:\s*(.+)\n',
|
|
|
297 |
'registrar': 'REGISTRAR:\n\s*(.+)',
|
|
|
298 |
'registrar_url': 'URL:\s*(.+)', # not available
|
|
|
299 |
'status': 'Registration status:\n\s*(.+)', # not available
|
|
|
300 |
'registrant_name': 'Registrant:\n\s*(.+)', # not available
|
|
|
301 |
'creation_date': 'created:\s*(.+)\n',
|
|
|
302 |
'expiration_date': 'renewal date:\s*(.+)',
|
|
|
303 |
'updated_date': 'last modified:\s*(.+)\n',
|
|
|
304 |
}
|
|
|
305 |
def __init__(self, domain, text):
|
|
|
306 |
if 'Not found:' in text:
|
|
|
307 |
raise PywhoisError(text)
|
|
|
308 |
else:
|
|
|
309 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
|
310 |
|
|
5
|
311 |
|
|
0
|
312 |
class WhoisMe(WhoisEntry):
|
|
|
313 |
"""Whois parser for .me domains
|
|
|
314 |
"""
|
|
|
315 |
regex = {
|
|
|
316 |
'domain_id': 'Domain ID:(.+)',
|
|
|
317 |
'domain_name': 'Domain Name:(.+)',
|
|
|
318 |
'creation_date': 'Domain Create Date:(.+)',
|
|
|
319 |
'updated_date': 'Domain Last Updated Date:(.+)',
|
|
|
320 |
'expiration_date': 'Domain Expiration Date:(.+)',
|
|
|
321 |
'transfer_date': 'Last Transferred Date:(.+)',
|
|
|
322 |
'trademark_name': 'Trademark Name:(.+)',
|
|
|
323 |
'trademark_country': 'Trademark Country:(.+)',
|
|
|
324 |
'trademark_number': 'Trademark Number:(.+)',
|
|
|
325 |
'trademark_application_date': 'Date Trademark Applied For:(.+)',
|
|
|
326 |
'trademark_registration_date': 'Date Trademark Registered:(.+)',
|
|
|
327 |
'registrar': 'Sponsoring Registrar:(.+)',
|
|
|
328 |
'created_by': 'Created by:(.+)',
|
|
|
329 |
'updated_by': 'Last Updated by Registrar:(.+)',
|
|
|
330 |
'status': 'Domain Status:(.+)', # list of statuses
|
|
|
331 |
'registrant_id': 'Registrant ID:(.+)',
|
|
|
332 |
'registrant_name': 'Registrant Name:(.+)',
|
|
|
333 |
'registrant_org': 'Registrant Organization:(.+)',
|
|
|
334 |
'registrant_address': 'Registrant Address:(.+)',
|
|
|
335 |
'registrant_address2': 'Registrant Address2:(.+)',
|
|
|
336 |
'registrant_address3': 'Registrant Address3:(.+)',
|
|
|
337 |
'registrant_city': 'Registrant City:(.+)',
|
|
|
338 |
'registrant_state_province': 'Registrant State/Province:(.+)',
|
|
|
339 |
'registrant_country': 'Registrant Country/Economy:(.+)',
|
|
|
340 |
'registrant_postal_code': 'Registrant Postal Code:(.+)',
|
|
|
341 |
'registrant_phone': 'Registrant Phone:(.+)',
|
|
|
342 |
'registrant_phone_ext': 'Registrant Phone Ext\.:(.+)',
|
|
|
343 |
'registrant_fax': 'Registrant FAX:(.+)',
|
|
|
344 |
'registrant_fax_ext': 'Registrant FAX Ext\.:(.+)',
|
|
|
345 |
'registrant_email': 'Registrant E-mail:(.+)',
|
|
|
346 |
'admin_id': 'Admin ID:(.+)',
|
|
|
347 |
'admin_name': 'Admin Name:(.+)',
|
|
|
348 |
'admin_org': 'Admin Organization:(.+)',
|
|
|
349 |
'admin_address': 'Admin Address:(.+)',
|
|
|
350 |
'admin_address2': 'Admin Address2:(.+)',
|
|
|
351 |
'admin_address3': 'Admin Address3:(.+)',
|
|
|
352 |
'admin_city': 'Admin City:(.+)',
|
|
|
353 |
'admin_state_province': 'Admin State/Province:(.+)',
|
|
|
354 |
'admin_country': 'Admin Country/Economy:(.+)',
|
|
|
355 |
'admin_postal_code': 'Admin Postal Code:(.+)',
|
|
|
356 |
'admin_phone': 'Admin Phone:(.+)',
|
|
|
357 |
'admin_phone_ext': 'Admin Phone Ext\.:(.+)',
|
|
|
358 |
'admin_fax': 'Admin FAX:(.+)',
|
|
|
359 |
'admin_fax_ext': 'Admin FAX Ext\.:(.+)',
|
|
|
360 |
'admin_email': 'Admin E-mail:(.+)',
|
|
|
361 |
'tech_id': 'Tech ID:(.+)',
|
|
|
362 |
'tech_name': 'Tech Name:(.+)',
|
|
|
363 |
'tech_org': 'Tech Organization:(.+)',
|
|
|
364 |
'tech_address': 'Tech Address:(.+)',
|
|
|
365 |
'tech_address2': 'Tech Address2:(.+)',
|
|
|
366 |
'tech_address3': 'Tech Address3:(.+)',
|
|
|
367 |
'tech_city': 'Tech City:(.+)',
|
|
|
368 |
'tech_state_province': 'Tech State/Province:(.+)',
|
|
|
369 |
'tech_country': 'Tech Country/Economy:(.+)',
|
|
|
370 |
'tech_postal_code': 'Tech Postal Code:(.+)',
|
|
|
371 |
'tech_phone': 'Tech Phone:(.+)',
|
|
|
372 |
'tech_phone_ext': 'Tech Phone Ext\.:(.+)',
|
|
|
373 |
'tech_fax': 'Tech FAX:(.+)',
|
|
|
374 |
'tech_fax_ext': 'Tech FAX Ext\.:(.+)',
|
|
|
375 |
'tech_email': 'Tech E-mail:(.+)',
|
|
|
376 |
'name_servers': 'Nameservers:(.+)', # list of name servers
|
|
|
377 |
}
|
|
|
378 |
def __init__(self, domain, text):
|
|
|
379 |
if 'NOT FOUND' in text:
|
|
|
380 |
raise PywhoisError(text)
|
|
|
381 |
else:
|
|
|
382 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
|
383 |
|
|
5
|
384 |
|
|
0
|
385 |
class WhoisUk(WhoisEntry):
|
|
|
386 |
"""Whois parser for .uk domains
|
|
|
387 |
"""
|
|
|
388 |
regex = {
|
|
|
389 |
'domain_name': 'Domain name:\n\s*(.+)',
|
|
|
390 |
'registrar': 'Registrar:\n\s*(.+)',
|
|
|
391 |
'registrar_url': 'URL:\s*(.+)',
|
|
|
392 |
'status': 'Registration status:\n\s*(.+)', # list of statuses
|
|
|
393 |
'registrant_name': 'Registrant:\n\s*(.+)',
|
|
|
394 |
'creation_date': 'Registered on:\s*(.+)',
|
|
5
|
395 |
'expiration_date': 'Expiry date:\s*(.+)',
|
|
0
|
396 |
'updated_date': 'Last updated:\s*(.+)',
|
|
3
|
397 |
'name_servers': 'Name servers:\s*(.+)',
|
|
0
|
398 |
}
|
|
|
399 |
def __init__(self, domain, text):
|
|
|
400 |
if 'Not found:' in text:
|
|
|
401 |
raise PywhoisError(text)
|
|
|
402 |
else:
|
|
|
403 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
2
|
404 |
|
|
4
|
405 |
|
|
|
406 |
class WhoisFr(WhoisEntry):
|
|
|
407 |
"""Whois parser for .fr domains
|
|
|
408 |
"""
|
|
|
409 |
regex = {
|
|
|
410 |
'domain_name': 'domain:\s*(.+)',
|
|
|
411 |
'registrar': 'registrar:\s*(.+)',
|
|
|
412 |
'creation_date': 'created:\s*(.+)',
|
|
|
413 |
'expiration_date': 'anniversary:\s*(.+)',
|
|
|
414 |
'name_servers': 'nserver:\s*(.+)', # list of name servers
|
|
|
415 |
'status': 'status:\s*(.+)', # list of statuses
|
|
|
416 |
'emails': '[\w.-]+@[\w.-]+\.[\w]{2,4}', # list of email addresses
|
|
|
417 |
'updated_date': 'last-update:\s*(.+)',
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
def __init__(self, domain, text):
|
|
|
421 |
if text.strip() == 'No entries found':
|
|
|
422 |
raise PywhoisError(text)
|
|
|
423 |
else:
|
|
|
424 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
|
425 |
|
|
|
426 |
|
|
2
|
427 |
class WhoisFi(WhoisEntry):
|
|
|
428 |
"""Whois parser for .fi domains
|
|
|
429 |
"""
|
|
|
430 |
regex = {
|
|
|
431 |
'domain_name': 'domain:\s*([\S]+)',
|
|
|
432 |
'registrant_name': 'descr:\s*([\S\ ]+)',
|
|
|
433 |
'registrant_address': 'address:\s*([\S\ ]+)',
|
|
|
434 |
'registrant_phone': 'phone:\s*([\S\ ]+)',
|
|
|
435 |
'status': 'status:\s*([\S]+)', # list of statuses
|
|
|
436 |
'creation_date': 'created:\s*([\S]+)',
|
|
|
437 |
'updated_date': 'modified:\s*([\S]+)',
|
|
|
438 |
'expiration_date': 'expires:\s*([\S]+)',
|
|
13
|
439 |
'name_servers': 'nserver:\s*([\S]+) \[\S+\]', # list of name servers
|
|
|
440 |
'name_server_statuses': 'nserver:\s*([\S]+) \[(\S+)\]', # list of name servers and statuses
|
|
|
441 |
'dnssec': 'dnssec:\s*([\S]+)',
|
|
2
|
442 |
}
|
|
|
443 |
def __init__(self, domain, text):
|
|
13
|
444 |
if 'Domain not ' in text:
|
|
2
|
445 |
raise PywhoisError(text)
|
|
|
446 |
else:
|
|
|
447 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
5
|
448 |
|
|
|
449 |
|
|
|
450 |
class WhoisJp(WhoisEntry):
|
|
|
451 |
"""Whois parser for .jp domains
|
|
|
452 |
"""
|
|
|
453 |
regex = {
|
|
|
454 |
'domain_name': 'a\. \[Domain Name\]\s*(.+)',
|
|
|
455 |
'registrant_org': 'g\. \[Organization\](.+)',
|
|
|
456 |
'creation_date': r'\[Registered Date\]\s*(.+)',
|
|
|
457 |
'name_servers': 'p\. \[Name Server\]\s*(.+)', # list of name servers
|
|
|
458 |
'updated_date': '\[Last Update\]\s?(.+)',
|
|
|
459 |
'status': '\[State\]\s*(.+)', # list of statuses
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
def __init__(self, domain, text):
|
|
|
463 |
if text.strip() == 'No entries found':
|
|
|
464 |
raise PywhoisError(text)
|
|
|
465 |
else:
|
|
|
466 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
15
|
467 |
|
|
17
|
468 |
|
|
|
469 |
class WhoisAU(WhoisEntry):
|
|
|
470 |
"""Whois parser for .au domains
|
|
|
471 |
"""
|
|
|
472 |
regex = {
|
|
|
473 |
'domain_name': 'Domain Name:\s*(.+)\n',
|
|
|
474 |
'last_modified': 'Last Modified:\s*(.+)\n',
|
|
|
475 |
'registrar': 'Registrar Name:\s*(.+)\n',
|
|
|
476 |
'status': 'Status:\s*(.+)',
|
|
|
477 |
'registrant_name': 'Registrant:\s*(.+)',
|
|
|
478 |
'name_servers': 'Name Server:\s*(.+)',
|
|
|
479 |
}
|
|
|
480 |
def __init__(self, domain, text):
|
|
|
481 |
if text.strip() == 'No Data Found':
|
|
|
482 |
raise PywhoisError(text)
|
|
|
483 |
else:
|
|
|
484 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
|
485 |
|
|
|
486 |
|
|
15
|
487 |
class WhoisBr(WhoisEntry):
|
|
|
488 |
"""Whois parser for .br domains
|
|
|
489 |
"""
|
|
|
490 |
regex = {
|
|
|
491 |
'domain': 'domain:\s*(.+)\n',
|
|
|
492 |
'owner': 'owner:\s*([\S ]+)',
|
|
|
493 |
'ownerid': 'ownerid:\s*(.+)',
|
|
|
494 |
'country': 'country:\s*(.+)',
|
|
|
495 |
'owner_c': 'owner-c:\s*(.+)',
|
|
|
496 |
'admin_c': 'admin-c:\s*(.+)',
|
|
|
497 |
'tech_c': 'tech-c:\s*(.+)',
|
|
|
498 |
'billing_c': 'billing-c:\s*(.+)',
|
|
|
499 |
'nserver': 'nserver:\s*(.+)',
|
|
|
500 |
'nsstat': 'nsstat:\s*(.+)',
|
|
|
501 |
'nslastaa': 'nslastaa:\s*(.+)',
|
|
|
502 |
'saci': 'saci:\s*(.+)',
|
|
|
503 |
'created': 'created:\s*(.+)',
|
|
|
504 |
'expires': 'expires:\s*(.+)',
|
|
|
505 |
'changed': 'changed:\s*(.+)',
|
|
|
506 |
'status': 'status:\s*(.+)',
|
|
|
507 |
'nic_hdl_br': 'nic-hdl-br:\s*(.+)',
|
|
|
508 |
'person': 'person:\s*([\S ]+)',
|
|
|
509 |
'email': 'e-mail:\s*(.+)',
|
|
|
510 |
}
|
|
|
511 |
|
|
|
512 |
def __init__(self, domain, text):
|
|
|
513 |
|
|
|
514 |
if 'Not found:' in text:
|
|
|
515 |
raise PywhoisError(text)
|
|
|
516 |
else:
|
|
|
517 |
WhoisEntry.__init__(self, domain, text, self.regex)
|
|
|
518 |
|