Skip to content

Commit

Permalink
Merge pull request #239 from sindrig/master
Browse files Browse the repository at this point in the history
Add parsing for .lv domains
  • Loading branch information
richardpenman authored Sep 4, 2024
2 parents a035732 + 478557b commit 34b04e0
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/samples/expected/google.lv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"domain_name": "google.lv", "registrant_name": "Google LLC", "registrant_address": "1600 Amphitheatre Parkway, Mountain View, CA, 94043, USA", "tech_name": null, "tech_address": null, "registrar_name": "MarkMonitor Inc.", "registrar_address": "1120 S. Rackham Way, Suite 300, Meridian, ID, 83642, USA", "name_servers": ["ns1.google.com", "ns2.google.com", "ns3.google.com", "ns4.google.com"], "updated_date": "2024-09-03 17:12:28.647770+00:00"}
46 changes: 46 additions & 0 deletions test/samples/whois/google.lv
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[Domain]
Domain: google.lv
Status: active

[Holder]
Type: Legal person
Name: Google LLC
Address: 1600 Amphitheatre Parkway, Mountain View, CA, 94043, USA
RegNr: None
Visit: https://www.nic.lv/whois/contact/google.lv to contact.

[Tech]
Type: Natural person
Visit: https://www.nic.lv/whois/contact/google.lv to contact.

[Registrar]
Type: Legal person
Name: MarkMonitor Inc.
Address: 1120 S. Rackham Way, Suite 300, Meridian, ID, 83642, USA
RegNr: 82-0513468
Visit: https://www.nic.lv/whois/contact/google.lv to contact.

[Nservers]
Nserver: ns1.google.com
Nserver: ns2.google.com
Nserver: ns3.google.com
Nserver: ns4.google.com

[Whois]
Updated: 2024-09-03T17:12:28.647770+00:00

[Disclaimer]
% The WHOIS service is provided solely for informational purposes.
%
% It is permitted to use the WHOIS service only for technical or administrative
% needs associated with the operation of the Internet or in order to contact
% the domain name holder over legal problems.
%
% Requestor will not use information obtained using WHOIS:
% * To allow, enable or in any other way to support sending of unsolicited mails (spam)
% * for any kind of advertising
% * to disrupt Internet stability and security
%
% It is not permitted to obtain (including copying) or re-use in any form or
% by any means all or quantitatively or qualitatively significant part
% of the WHOIS without NIC's express permission.
23 changes: 23 additions & 0 deletions whois/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ def load(domain, text):
return WhoisSite(domain, text)
elif domain.endswith(".edu"):
return WhoisEdu(domain, text)
elif domain.endswith(".lv"):
return WhoisLv(domain, text)
else:
return WhoisEntry(domain, text)

Expand Down Expand Up @@ -3403,3 +3405,24 @@ def __init__(self, domain, text):
raise PywhoisError(text)
else:
WhoisEntry.__init__(self, domain, text, self.regex)

class WhoisLv(WhoisEntry):
"""Whois parser for .lv domains"""

regex = {
"domain_name": r"\[Domain\]\nDomain: *(.+)",
"registrant_name": r"\[Holder\]\n\s+Type: .*\n\s+Name: *(.+)",
"registrant_address": r"\[Holder\]\n\s+Type: .*\n\s+Name: .*\n\s+Address: *(.+)",
"tech_name": r"\[Tech\]\n\s+Type: .*\n\s+Name: *(.+)",
"tech_address": r"\[Tech\]\n\s+Type: .*\n\s+Name: .*\n\s+Address: *(.+)",
"registrar_name": r"\[Registrar\]\n\s+Type: .*\n\s+Name: *(.+)",
"registrar_address": r"\[Registrar\]\n\s+Type: .*\n\s+Name: .*\n\s+Address: *(.+)",
"name_servers": r"Nserver: *(.+)",
"updated_date": r"\[Whois\]\nUpdated: (.+)",
}

def __init__(self, domain, text):
if "Status: free" in text:
raise PywhoisError(text)
else:
WhoisEntry.__init__(self, domain, text, self.regex)

0 comments on commit 34b04e0

Please sign in to comment.