From e1c419cfaa82b6566e17786e241c4b0a75d33cd5 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 21 Sep 2012 05:55:31 +0200 Subject: [PATCH] Add parsing syntax for .us domains and similar --- pythonwhois/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pythonwhois/__init__.py b/pythonwhois/__init__.py index 55b12c0..d41310f 100644 --- a/pythonwhois/__init__.py +++ b/pythonwhois/__init__.py @@ -21,20 +21,23 @@ grammar = { 'Domain Created\s?[.]*:\s?(?P.+)', 'Domain registered\s?[.]*:\s?(?P.+)', 'Domain record activated\s?[.]*:\s*?(?P.+)', - 'Record created on\s?[.]*:?\s*?(?P.+)'], + 'Record created on\s?[.]*:?\s*?(?P.+)', + 'Domain Registration Date\s?[.]*:?\s*?(?P.+)'], 'expiration_date': ['Expires on:\s?(?P.+)', 'Expires on\s?[.]*:\s?(?P.+)\.', 'Expiry Date\s?[.]*:\s?(?P.+)', 'Domain Currently Expires\s?[.]*:\s?(?P.+)', 'Record will expire on\s?[.]*:\s?(?P.+)', 'Domain expires\s?[.]*:\s*?(?P.+)', - 'Record expires on\s?[.]*:?\s*?(?P.+)'], + 'Record expires on\s?[.]*:?\s*?(?P.+)', + 'Domain Expiration Date\s?[.]*:?\s*?(?P.+)'], 'updated_date': ['Database last updated on\s?[.]*:?\s*?(?P.+)\s[a-z]+\.?', 'Record last updated on\s?[.]*:\s?(?P.+)\.', 'Domain record last updated\s?[.]*:\s*?(?P.+)', 'Domain Last Updated\s?[.]*:\s*?(?P.+)', 'Last updated on:\s?(?P.+)', 'Date Modified\s?[.]*:\s?(?P.+)', + 'Domain Last Updated Date\s?[.]*:\s?(?P.+)', 'Last update of whois database:\s?[a-z]{3}, (?P.+) [a-z]{3}'], 'registrar': ['Registered through:\s?(?P.+)', 'Registrar Name:\s?(?P.+)', @@ -49,6 +52,9 @@ grammar = { "_dateformats": ( '(?P[0-9]{1,2})[./ -](?PJan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[./ -](?P[0-9]{4}|[0-9]{2})' '(\s+(?P[0-9]{1,2})[:.](?P[0-9]{1,2})[:.](?P[0-9]{1,2}))?', + '[a-z]{3}\s(?PJan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[./ -](?P[0-9]{1,2})' + '(\s+(?P[0-9]{1,2})[:.](?P[0-9]{1,2})[:.](?P[0-9]{1,2}))?' + '\s[a-z]{3}\s(?P[0-9]{4}|[0-9]{2})', '(?P[0-9]{4})[./-](?P[0-9]{1,2})[./-](?P[0-9]{1,2})', '(?P[0-9]{1,2})[./ -](?P[0-9]{1,2})[./ -](?P[0-9]{4}|[0-9]{2})' ), @@ -158,14 +164,14 @@ def parse_dates(dates): for date in dates: for rule in grammar['_dateformats']: - result = re.match(rule, date) + result = re.match(rule, date, re.IGNORECASE) if result is not None: try: # These are always numeric. If they fail, there is no valid date present. year = int(result.group("year")) day = int(result.group("day")) - + # This will require some more guesswork - some WHOIS servers present the name of the month try: month = int(result.group("month"))