mirror of
https://github.com/joepie91/python-whois.git
synced 2026-02-04 03:16:51 -06:00
Implement nic.ir parsing, including their horrid address format. Partially fixes #23.
This commit is contained in:
parent
d9474ce1b3
commit
84ab775649
@ -53,6 +53,7 @@ grammar = {
|
||||
'Domain Expiration Date\s?[.]*:?\s*?(?P<val>.+)',
|
||||
'paid-till:\s*(?P<val>.+)',
|
||||
'expiration_date:\s*(?P<val>.+)',
|
||||
'expire-date:\s*(?P<val>.+)',
|
||||
'renewal:\s*(?P<val>.+)',
|
||||
'expire:\s*(?P<val>.+)'],
|
||||
'updated_date': ['\[Last Updated\]\s*(?P<val>.+)',
|
||||
@ -75,6 +76,7 @@ grammar = {
|
||||
'Last Update\s?[.]*:\s?(?P<val>.+)',
|
||||
'Last updated on (?P<val>.+) [a-z]{3,4}',
|
||||
'Last updated:\s*(?P<val>.+)',
|
||||
'last-updated:\s*(?P<val>.+)',
|
||||
'\[Last Update\]\s*(?P<val>.+) \([A-Z]+\)',
|
||||
'Last update of whois database:\s?[a-z]{3}, (?P<val>.+) [a-z]{3,4}'],
|
||||
'registrar': ['registrar:\s*(?P<val>.+)',
|
||||
@ -745,9 +747,10 @@ def parse_registrants(data, never_query_handles=True, handle_server=""):
|
||||
lines = [x.strip() for x in obj["street"].splitlines()]
|
||||
if " " in lines[-1]:
|
||||
postal_code, city = lines[-1].split(" ", 1)
|
||||
obj["postalcode"] = postal_code
|
||||
obj["city"] = city
|
||||
obj["street"] = "\n".join(lines[:-1])
|
||||
if "." not in lines[-1] and re.match("[0-9]", postal_code) and len(postal_code) >= 3:
|
||||
obj["postalcode"] = postal_code
|
||||
obj["city"] = city
|
||||
obj["street"] = "\n".join(lines[:-1])
|
||||
if 'firstname' in obj or 'lastname' in obj:
|
||||
elements = []
|
||||
if 'firstname' in obj:
|
||||
@ -779,6 +782,8 @@ def parse_nic_contact(data):
|
||||
"contact-handle:[ ]*(?P<handle>.+)\ncontact:[ ]*(?P<name>.+)\n(?:organisation:[ ]*(?P<organization>.+)\n)?address:[ ]*(?P<street1>.+)\n(?:address:[ ]*(?P<street2>.+)\n)?(?:address:[ ]*(?P<street3>.+)\n)?(?:address:[ ]*(?P<street4>.+)\n)?address:[ ]*(?P<city>.+)\naddress:[ ]*(?P<state>.+)\naddress:[ ]*(?P<postalcode>.+)\naddress:[ ]*(?P<country>.+)\n(?:phone:[ ]*(?P<phone>.+)\n)?(?:fax:[ ]*(?P<fax>.+)\n)?(?:email:[ ]*(?P<email>.+)\n)?", # LCN.com
|
||||
"Contact Information:\na\. \[JPNIC Handle\] (?P<handle>.+)\nc\. \[Last, First\] (?P<lastname>.+), (?P<firstname>.+)\nd\. \[E-Mail\] (?P<email>.+)\ng\. \[Organization\] (?P<organization>.+)\nl\. \[Division\] (?P<division>.+)\nn\. \[Title\] (?P<title>.+)\no\. \[TEL\] (?P<phone>.+)\np\. \[FAX\] (?P<fax>.+)\ny\. \[Reply Mail\] .*\n\[Last Update\] (?P<changedate>.+) \(JST\)\n", # JPRS .co.jp contact handle lookup
|
||||
"person:\s*(?P<name>.+)\nnic-hdl:\s*(?P<handle>.+)\n", # .ie
|
||||
"nic-hdl:\s+(?P<handle>.+)\nperson:\s+(?P<name>.+)\n(?:e-mail:\s+(?P<email>.+)\n)?(?:address:\s+(?P<street1>.+?)(?:,+ (?P<street2>.+?)(?:,+ (?P<street3>.+?)(?:,+ (?P<street4>.+?)(?:,+ (?P<street5>.+?)(?:,+ (?P<street6>.+?)(?:,+ (?P<street7>.+?))?)?)?)?)?)?, (?P<city>.+), (?P<state>.+), (?P<country>.+)\n)?(?:phone:\s+(?P<phone>.+)\n)?(?:fax-no:\s+(?P<fax>.+)\n)?", # nic.ir, individual - this is a nasty one.
|
||||
"nic-hdl:\s+(?P<handle>.+)\norg:\s+(?P<organization>.+)\n(?:e-mail:\s+(?P<email>.+)\n)?(?:address:\s+(?P<street1>.+?)(?:,+ (?P<street2>.+?)(?:,+ (?P<street3>.+?)(?:,+ (?P<street4>.+?)(?:,+ (?P<street5>.+?)(?:,+ (?P<street6>.+?)(?:,+ (?P<street7>.+?))?)?)?)?)?)?, (?P<city>.+), (?P<state>.+), (?P<country>.+)\n)?(?:phone:\s+(?P<phone>.+)\n)?(?:fax-no:\s+(?P<fax>.+)\n)?", # nic.ir, organization
|
||||
"nic-hdl:\s*(?P<handle>.+)\ntype:\s*(?P<type>.+)\ncontact:\s*(?P<name>.+)\n(?:.+\n)*?(?:address:\s*(?P<street1>.+)\naddress:\s*(?P<street2>.+)\naddress:\s*(?P<street3>.+)\naddress:\s*(?P<country>.+)\n)?(?:phone:\s*(?P<phone>.+)\n)?(?:fax-no:\s*(?P<fax>.+)\n)?(?:.+\n)*?(?:e-mail:\s*(?P<email>.+)\n)?(?:.+\n)*?changed:\s*(?P<changedate>[0-9]{2}\/[0-9]{2}\/[0-9]{4}).*\n", # AFNIC madness without country field
|
||||
"nic-hdl:\s*(?P<handle>.+)\ntype:\s*(?P<type>.+)\ncontact:\s*(?P<name>.+)\n(?:.+\n)*?(?:address:\s*(?P<street1>.+)\n)?(?:address:\s*(?P<street2>.+)\n)?(?:address:\s*(?P<street3>.+)\n)?(?:phone:\s*(?P<phone>.+)\n)?(?:fax-no:\s*(?P<fax>.+)\n)?(?:.+\n)*?(?:e-mail:\s*(?P<email>.+)\n)?(?:.+\n)*?changed:\s*(?P<changedate>[0-9]{2}\/[0-9]{2}\/[0-9]{4}).*\n", # AFNIC madness any country -at all-
|
||||
"nic-hdl:\s*(?P<handle>.+)\ntype:\s*(?P<type>.+)\ncontact:\s*(?P<name>.+)\n(?:.+\n)*?(?:address:\s*(?P<street1>.+)\n)?(?:address:\s*(?P<street2>.+)\n)?(?:address:\s*(?P<street3>.+)\n)?(?:address:\s*(?P<street4>.+)\n)?country:\s*(?P<country>.+)\n(?:phone:\s*(?P<phone>.+)\n)?(?:fax-no:\s*(?P<fax>.+)\n)?(?:.+\n)*?(?:e-mail:\s*(?P<email>.+)\n)?(?:.+\n)*?changed:\s*(?P<changedate>[0-9]{2}\/[0-9]{2}\/[0-9]{4}).*\n", # AFNIC madness with country field
|
||||
|
||||
45
test/data/nic.ir
Normal file
45
test/data/nic.ir
Normal file
@ -0,0 +1,45 @@
|
||||
% This is the IRNIC Whois server v1.6.2.
|
||||
% Available on web at http://whois.nic.ir/
|
||||
% Find the terms and conditions of use on http://www.nic.ir/
|
||||
%
|
||||
% This server uses UTF-8 as the encoding for requests and responses.
|
||||
|
||||
% NOTE: This output has been filtered.
|
||||
|
||||
% Information related to 'nic.ir'
|
||||
|
||||
|
||||
domain: nic.ir
|
||||
ascii: nic.ir
|
||||
remarks: (Domain Holder) Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)
|
||||
remarks: (Domain Holder Address) Shahid Bahonar (Niavaran) Sq., Tehran, Tehran, IR
|
||||
holder-c: ir00-irnic
|
||||
admin-c: ir00-irnic
|
||||
tech-c: as51-irnic
|
||||
nserver: ns1.nic.ir
|
||||
nserver: ns.nic.ir
|
||||
nserver: ns5.univie.ac.at
|
||||
nserver: auth51.ns.uu.net
|
||||
last-updated: 2010-05-09
|
||||
expire-date: 2015-05-26
|
||||
source: IRNIC # Filtered
|
||||
|
||||
nic-hdl: ir00-irnic
|
||||
org: Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)
|
||||
e-mail: info@nic.ir
|
||||
address: Shahid Bahonar (Niavaran) Sq., Tehran, Tehran, IR
|
||||
phone: +98 21 2229 0306
|
||||
fax-no: +98 21 2229 5700
|
||||
source: IRNIC # Filtered
|
||||
|
||||
nic-hdl: as51-irnic
|
||||
person: Alireza Saleh
|
||||
e-mail: arsaleh@gmail.com
|
||||
source: IRNIC # Filtered
|
||||
|
||||
domain: nic.ir
|
||||
ascii: nic.ir
|
||||
remarks: This domain is only available for registration under certain conditions
|
||||
source: IRNIC # Filtered
|
||||
|
||||
|
||||
32
test/data/whoiser.ir
Normal file
32
test/data/whoiser.ir
Normal file
@ -0,0 +1,32 @@
|
||||
% This is the IRNIC Whois server v1.6.2.
|
||||
% Available on web at http://whois.nic.ir/
|
||||
% Find the terms and conditions of use on http://www.nic.ir/
|
||||
%
|
||||
% This server uses UTF-8 as the encoding for requests and responses.
|
||||
|
||||
% NOTE: This output has been filtered.
|
||||
|
||||
% Information related to 'whoiser.ir'
|
||||
|
||||
|
||||
domain: whoiser.ir
|
||||
ascii: whoiser.ir
|
||||
remarks: (Domain Holder) Mohsen Jadidi
|
||||
remarks: (Domain Holder Address) Andishe, Faz 3, Mahale 23 St., Shahed St., Baharan St., No. 12,, Shahraiar, Tehran, IR
|
||||
holder-c: mj205-irnic
|
||||
admin-c: mj205-irnic
|
||||
tech-c: mj205-irnic
|
||||
nserver: ns1.webmasir.com
|
||||
nserver: ns2.webmasir.com
|
||||
last-updated: 2014-06-01
|
||||
expire-date: 2017-03-03
|
||||
source: IRNIC # Filtered
|
||||
|
||||
nic-hdl: mj205-irnic
|
||||
person: Mohsen Jadidi
|
||||
e-mail: mnjadidi@gmail.com
|
||||
address: Andishe, Faz 3, Mahale 23 St., Shahed St., Baharan St., No. 12,, Shahraiar, Tehran, IR
|
||||
phone: +982623554491
|
||||
source: IRNIC # Filtered
|
||||
|
||||
|
||||
1
test/target_default/nic.ir
Normal file
1
test/target_default/nic.ir
Normal file
@ -0,0 +1 @@
|
||||
{"updated_date": ["2010-05-09T00:00:00"], "contacts": {"admin": {"fax": "+98 21 2229 5700", "handle": "ir00-irnic", "phone": "+98 21 2229 0306", "street": "Shahid Bahonar (Niavaran) Sq.", "city": "Tehran", "country": "IR", "state": "Tehran", "organization": "Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)", "email": "info@nic.ir"}, "tech": {"handle": "as51-irnic", "name": "Alireza Saleh", "email": "arsaleh@gmail.com"}, "registrant": {"fax": "+98 21 2229 5700", "handle": "ir00-irnic", "phone": "+98 21 2229 0306", "street": "Shahid Bahonar (Niavaran) Sq.", "city": "Tehran", "country": "IR", "state": "Tehran", "organization": "Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)", "email": "info@nic.ir"}, "billing": null}, "nameservers": ["ns1.nic.ir", "ns.nic.ir", "ns5.univie.ac.at", "auth51.ns.uu.net"], "expiration_date": ["2015-05-26T00:00:00"], "raw": ["% This is the IRNIC Whois server v1.6.2.\n% Available on web at http://whois.nic.ir/\n% Find the terms and conditions of use on http://www.nic.ir/\n% \n% This server uses UTF-8 as the encoding for requests and responses.\n\n% NOTE: This output has been filtered.\n\n% Information related to 'nic.ir'\n\n\ndomain:\t\tnic.ir\nascii:\t\tnic.ir\nremarks:\t(Domain Holder) Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)\nremarks:\t(Domain Holder Address) Shahid Bahonar (Niavaran) Sq., Tehran, Tehran, IR\nholder-c:\tir00-irnic\nadmin-c:\tir00-irnic\ntech-c:\t\tas51-irnic\nnserver:\tns1.nic.ir\nnserver:\tns.nic.ir\nnserver:\tns5.univie.ac.at\nnserver:\tauth51.ns.uu.net\nlast-updated:\t2010-05-09\nexpire-date:\t2015-05-26\nsource:\t\tIRNIC # Filtered\n\nnic-hdl:\tir00-irnic\norg:\t\tDot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)\ne-mail:\t\tinfo@nic.ir\naddress:\tShahid Bahonar (Niavaran) Sq., Tehran, Tehran, IR\nphone:\t\t+98 21 2229 0306\nfax-no:\t\t+98 21 2229 5700\nsource:\t\tIRNIC # Filtered\n\nnic-hdl:\tas51-irnic\nperson:\t\tAlireza Saleh\ne-mail:\t\tarsaleh@gmail.com\nsource:\t\tIRNIC # Filtered\n\ndomain:\t\tnic.ir\nascii:\t\tnic.ir\nremarks:\tThis domain is only available for registration under certain conditions\nsource:\t\tIRNIC # Filtered\n\n\n"]}
|
||||
1
test/target_default/whoiser.ir
Normal file
1
test/target_default/whoiser.ir
Normal file
@ -0,0 +1 @@
|
||||
{"updated_date": ["2014-06-01T00:00:00"], "contacts": {"admin": {"handle": "mj205-irnic", "phone": "+982623554491", "street": "Andishe\nFaz 3\nMahale 23 St.\nShahed St.\nBaharan St.\nNo. 12,", "city": "Shahraiar", "name": "Mohsen Jadidi", "country": "IR", "state": "Tehran", "email": "mnjadidi@gmail.com"}, "tech": {"handle": "mj205-irnic", "phone": "+982623554491", "street": "Andishe\nFaz 3\nMahale 23 St.\nShahed St.\nBaharan St.\nNo. 12,", "city": "Shahraiar", "name": "Mohsen Jadidi", "country": "IR", "state": "Tehran", "email": "mnjadidi@gmail.com"}, "registrant": {"handle": "mj205-irnic", "phone": "+982623554491", "street": "Andishe\nFaz 3\nMahale 23 St.\nShahed St.\nBaharan St.\nNo. 12,", "city": "Shahraiar", "name": "Mohsen Jadidi", "country": "IR", "state": "Tehran", "email": "mnjadidi@gmail.com"}, "billing": null}, "nameservers": ["ns1.webmasir.com", "ns2.webmasir.com"], "expiration_date": ["2017-03-03T00:00:00"], "raw": ["% This is the IRNIC Whois server v1.6.2.\n% Available on web at http://whois.nic.ir/\n% Find the terms and conditions of use on http://www.nic.ir/\n% \n% This server uses UTF-8 as the encoding for requests and responses.\n\n% NOTE: This output has been filtered.\n\n% Information related to 'whoiser.ir'\n\n\ndomain:\t\twhoiser.ir\nascii:\t\twhoiser.ir\nremarks:\t(Domain Holder) Mohsen Jadidi\nremarks:\t(Domain Holder Address) Andishe, Faz 3, Mahale 23 St., Shahed St., Baharan St., No. 12,, Shahraiar, Tehran, IR\nholder-c:\tmj205-irnic\nadmin-c:\tmj205-irnic\ntech-c:\t\tmj205-irnic\nnserver:\tns1.webmasir.com\nnserver:\tns2.webmasir.com\nlast-updated:\t2014-06-01\nexpire-date:\t2017-03-03\nsource:\t\tIRNIC # Filtered\n\nnic-hdl:\tmj205-irnic\nperson:\t\tMohsen Jadidi\ne-mail:\t\tmnjadidi@gmail.com\naddress:\tAndishe, Faz 3, Mahale 23 St., Shahed St., Baharan St., No. 12,, Shahraiar, Tehran, IR\nphone:\t\t+982623554491\nsource:\t\tIRNIC # Filtered\n\n\n"]}
|
||||
1
test/target_normalized/nic.ir
Normal file
1
test/target_normalized/nic.ir
Normal file
@ -0,0 +1 @@
|
||||
{"updated_date": ["2010-05-09T00:00:00"], "contacts": {"admin": {"fax": "+98 21 2229 5700", "handle": "ir00-irnic", "phone": "+98 21 2229 0306", "street": "Shahid Bahonar (Niavaran) Sq.", "city": "Tehran", "country": "IR", "state": "Tehran", "organization": "Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)", "email": "info@nic.ir"}, "tech": {"handle": "as51-irnic", "name": "Alireza Saleh", "email": "arsaleh@gmail.com"}, "registrant": {"fax": "+98 21 2229 5700", "handle": "ir00-irnic", "phone": "+98 21 2229 0306", "street": "Shahid Bahonar (Niavaran) Sq.", "city": "Tehran", "country": "IR", "state": "Tehran", "organization": "Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)", "email": "info@nic.ir"}, "billing": null}, "nameservers": ["ns1.nic.ir", "ns.nic.ir", "ns5.univie.ac.at", "auth51.ns.uu.net"], "expiration_date": ["2015-05-26T00:00:00"], "raw": ["% This is the IRNIC Whois server v1.6.2.\n% Available on web at http://whois.nic.ir/\n% Find the terms and conditions of use on http://www.nic.ir/\n% \n% This server uses UTF-8 as the encoding for requests and responses.\n\n% NOTE: This output has been filtered.\n\n% Information related to 'nic.ir'\n\n\ndomain:\t\tnic.ir\nascii:\t\tnic.ir\nremarks:\t(Domain Holder) Dot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)\nremarks:\t(Domain Holder Address) Shahid Bahonar (Niavaran) Sq., Tehran, Tehran, IR\nholder-c:\tir00-irnic\nadmin-c:\tir00-irnic\ntech-c:\t\tas51-irnic\nnserver:\tns1.nic.ir\nnserver:\tns.nic.ir\nnserver:\tns5.univie.ac.at\nnserver:\tauth51.ns.uu.net\nlast-updated:\t2010-05-09\nexpire-date:\t2015-05-26\nsource:\t\tIRNIC # Filtered\n\nnic-hdl:\tir00-irnic\norg:\t\tDot-IR (.ir) ccTLD Registry, Institute for Studies in Theoretical Physics and Mathematics (IPM)\ne-mail:\t\tinfo@nic.ir\naddress:\tShahid Bahonar (Niavaran) Sq., Tehran, Tehran, IR\nphone:\t\t+98 21 2229 0306\nfax-no:\t\t+98 21 2229 5700\nsource:\t\tIRNIC # Filtered\n\nnic-hdl:\tas51-irnic\nperson:\t\tAlireza Saleh\ne-mail:\t\tarsaleh@gmail.com\nsource:\t\tIRNIC # Filtered\n\ndomain:\t\tnic.ir\nascii:\t\tnic.ir\nremarks:\tThis domain is only available for registration under certain conditions\nsource:\t\tIRNIC # Filtered\n\n\n"]}
|
||||
1
test/target_normalized/whoiser.ir
Normal file
1
test/target_normalized/whoiser.ir
Normal file
@ -0,0 +1 @@
|
||||
{"updated_date": ["2014-06-01T00:00:00"], "contacts": {"admin": {"handle": "mj205-irnic", "phone": "+982623554491", "street": "Andishe\nFaz 3\nMahale 23 St.\nShahed St.\nBaharan St.\nNo. 12", "city": "Shahraiar", "name": "Mohsen Jadidi", "country": "IR", "state": "Tehran", "email": "mnjadidi@gmail.com"}, "tech": {"handle": "mj205-irnic", "phone": "+982623554491", "street": "Andishe\nFaz 3\nMahale 23 St.\nShahed St.\nBaharan St.\nNo. 12", "city": "Shahraiar", "name": "Mohsen Jadidi", "country": "IR", "state": "Tehran", "email": "mnjadidi@gmail.com"}, "registrant": {"handle": "mj205-irnic", "phone": "+982623554491", "street": "Andishe\nFaz 3\nMahale 23 St.\nShahed St.\nBaharan St.\nNo. 12", "city": "Shahraiar", "name": "Mohsen Jadidi", "country": "IR", "state": "Tehran", "email": "mnjadidi@gmail.com"}, "billing": null}, "nameservers": ["ns1.webmasir.com", "ns2.webmasir.com"], "expiration_date": ["2017-03-03T00:00:00"], "raw": ["% This is the IRNIC Whois server v1.6.2.\n% Available on web at http://whois.nic.ir/\n% Find the terms and conditions of use on http://www.nic.ir/\n% \n% This server uses UTF-8 as the encoding for requests and responses.\n\n% NOTE: This output has been filtered.\n\n% Information related to 'whoiser.ir'\n\n\ndomain:\t\twhoiser.ir\nascii:\t\twhoiser.ir\nremarks:\t(Domain Holder) Mohsen Jadidi\nremarks:\t(Domain Holder Address) Andishe, Faz 3, Mahale 23 St., Shahed St., Baharan St., No. 12,, Shahraiar, Tehran, IR\nholder-c:\tmj205-irnic\nadmin-c:\tmj205-irnic\ntech-c:\t\tmj205-irnic\nnserver:\tns1.webmasir.com\nnserver:\tns2.webmasir.com\nlast-updated:\t2014-06-01\nexpire-date:\t2017-03-03\nsource:\t\tIRNIC # Filtered\n\nnic-hdl:\tmj205-irnic\nperson:\t\tMohsen Jadidi\ne-mail:\t\tmnjadidi@gmail.com\naddress:\tAndishe, Faz 3, Mahale 23 St., Shahed St., Baharan St., No. 12,, Shahraiar, Tehran, IR\nphone:\t\t+982623554491\nsource:\t\tIRNIC # Filtered\n\n\n"]}
|
||||
Loading…
x
Reference in New Issue
Block a user