Giter Club home page Giter Club logo

Comments (8)

DannyCork avatar DannyCork commented on May 28, 2024

An example of the issue

>>> domain = whois.query('cam.ac.uk')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/whois/__init__.py", line 67, in query
    return Domain(pd) if pd['domain_name'][0] else None
  File "/usr/local/lib/python3.6/dist-packages/whois/_3_adjust.py", line 14, in __init__
    self.creation_date = str_to_date(data['creation_date'][0])
  File "/usr/local/lib/python3.6/dist-packages/whois/_3_adjust.py", line 94, in str_to_date
    raise UnknownDateFormat("Unknown date format: '%s'" % text)
whois.exceptions.UnknownDateFormat: Unknown date format: 'before aug-1996'

from python-whois.

DannyCork avatar DannyCork commented on May 28, 2024

master has the fix, release to follow.

Thanks @brianosmith

>>> import whois
>>> domain = whois.query('cam.ac.uk')
>>> domain.__dict__
{'name': 'ac.uk', 'registrar': 'No registrar listed.  This domain is directly registered with Nominet.', 'creation_date': datetime.datetime(1996, 8, 1, 0, 0), 'expiration_date': None, 'last_updated': None, 'name_servers': {'ns0.ja.net'}}

from python-whois.

brianosmith avatar brianosmith commented on May 28, 2024

Swift work @DannyCork !

So you have seen the next issue I was going to raise too: looks like UK records don't follow the format of the .com etc. fields and there are several different styles of whois response for different types of .uk domain. Thus the cam.ac.uk (and other .ac.uk) query does not return a Domain Name: (but does return a Domain:) which falls foul of the current parsing rules at __init__.py line 63 and so gets chopped down to ac.uk which does return a Domain name: but loses the specific info sought.
I don't know the full range of possibilities here, but it looks as if, on picking a few random samples, that above the TLD, .ac.uk and .gov.uk are consistent in having Domain: while .org.uk (non-profit) and .co.uk (for profit) have Domain Name: . What's the best way to handle these - additional elif domain.endswith() calls in __init__.py ?

from python-whois.

brianosmith avatar brianosmith commented on May 28, 2024

Having stuck in

  elif domain.endswith('.ac.uk'):
       tld = 'ac_uk'

and modified tld_regexpr.py to catch this and interpret Domain: as domain_name I hit another nasty date format
whois.exceptions.UnknownDateFormat: Unknown date format: 'monday 23rd mar 2020'
which I hacked around by adding
'%A %d %b %Y', # Tuesday 21 Jun 2011
and
text = re.sub(r"(st|nd|rd|th) ", " ", text)
before the date format conversion attempt in _3_adjust.py. This latter is a nasty hack and some better options are found here
https://stackoverflow.com/questions/1258199/python-datetime-strptime-wildcard

from python-whois.

brianosmith avatar brianosmith commented on May 28, 2024

@DannyCork I can push you a branch with these changes in if you like.

from python-whois.

DannyCork avatar DannyCork commented on May 28, 2024

That would be a great Christmas present @brianosmith , thanks !

from python-whois.

dancvrcek avatar dancvrcek commented on May 28, 2024

Hi, just wonder if this has been resolved. I'm still getting an error :(

import whois
domain = whois.query('cam.ac.uk')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyenv3/lib/python3.7/site-packages/whois/__init__.py", line 63, in query
    return Domain(pd) if pd['domain_name'][0] else None
  File "pyenv3/lib/python3.7/site-packages/whois/_3_adjust.py", line 13, in __init__
    self.creation_date      = str_to_date(data['creation_date'][0])
  File pyenv3/lib/python3.7/site-packages/whois/_3_adjust.py", line 88, in str_to_date
    raise ValueError("Unknown date format: '%s'" % s)
ValueError: Unknown date format: 'before aug-1996'

from python-whois.

DannyCork avatar DannyCork commented on May 28, 2024

now working.

>>> domain = whois.query('cam.ac.uk')
>>> print (domain.__dict__)
{'name': 'cam.ac.uk', 'registrar': 'Jisc Services Limited', 'registrant_country': '', 'creation_date': datetime.datetime(2003, 9, 17, 0, 0), 'expiration_date': datetime.datetime(2022, 8, 13, 0, 0), 'last_updated': datetime.datetime(2020, 5, 13, 0, 0), 'status': '', 'statuses': [''], 'dnssec': False, 'name_servers': set(), 'owner': 'University of Cambridge'}

from python-whois.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.