Comments (8)
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.
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.
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.
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.
@DannyCork I can push you a branch with these changes in if you like.
from python-whois.
That would be a great Christmas present @brianosmith , thanks !
from python-whois.
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.
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)
- FileNotFoundError: [Errno 2] No such file or directory: 'whois': 'whois' HOT 3
- Module doesn't work in python 3.5.3 HOT 3
- The pypi version is not same as the github version (0.9.27), has "we have " prompt under _0_init_tld.py HOT 7
- org.uk, gov.uk need fixed HOT 6
- fyi HOT 1
- Support for additional missing TLDs (.gt, .my, .za, .ch) HOT 4
- Most new registered domains has no updated time, Parse error HOT 6
- any idea about adding params: available, expired, pendingDelete HOT 5
- Code in documentation didn't work HOT 2
- .se updated date parsing error HOT 2
- I think a try-except would be better when trying more details. HOT 6
- Whois on IP HOT 3
- status whois on pipy HOT 1
- Check if domain is available, not available or in redemption period HOT 8
- cmd parameter not being passed to do_query() HOT 2
- Proposal to Archive the repo HOT 11
- Add a redis cache HOT 3
- Can't fetch domain info in .ag zone. HOT 4
- unable to lookup .pro domains HOT 4
- Can I do unlimited requests? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-whois.