Skip to content

Commit 5bc64ba

Browse files
Merge pull request #291 from brondsem/add-hu-parser
add .hu parser
2 parents 3cb7626 + a7f937d commit 5bc64ba

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

test/samples/expected/google.hu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"domain_name": "google.hu", "expiration_date": null, "updated_date": null, "registrar": null, "registrar_url": null, "creation_date": "2000-03-03 00:00:00", "status": null}

test/samples/whois/google.hu

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
% Whois server 4.0 serving the hu ccTLD
2+
3+
4+
domain: google.hu
5+
record created: 2000-03-03
6+
Tovabbi adatokert ld.:
7+
https://www.domain.hu/domain-kereses/
8+
For further data see:
9+
https://www.domain.hu/domain-search/

whois/parser.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ def load(domain: str, text: str):
416416
return WhoisGa(domain, text)
417417
elif domain.endswith(".cm"):
418418
return WhoisCm(domain, text)
419+
elif domain.endswith(".hu"):
420+
return WhoisHu(domain, text)
419421
else:
420422
return WhoisEntry(domain, text)
421423

@@ -3523,3 +3525,18 @@ def __init__(self, domain: str, text: str):
35233525
raise WhoisDomainNotFoundError(text)
35243526
else:
35253527
WhoisEntry.__init__(self, domain, text, self.regex)
3528+
3529+
3530+
class WhoisHu(WhoisEntry):
3531+
"""Whois parser for .hu domains"""
3532+
3533+
regex: dict[str, str] = {
3534+
"domain_name": r"domain: *(.+)",
3535+
"creation_date": r"record created: *(.+)",
3536+
}
3537+
3538+
def __init__(self, domain: str, text: str):
3539+
if text.strip().endswith("No match"):
3540+
raise WhoisDomainNotFoundError(text)
3541+
else:
3542+
WhoisEntry.__init__(self, domain, text, self.regex)

0 commit comments

Comments
 (0)