mboot-github / python-whois

Python module/library for retrieving domain WHOIS information (only domain)
https://pypi.org/project/whois/
MIT License
287 stars 136 forks source link

Exception: Unknown TLD: ca #15

Closed GoogleCodeExporter closed 3 years ago

GoogleCodeExporter commented 9 years ago
$ cat a.py
import whois

domain = 'invisiblebracesintoronto.ca'
whois.query(domain, 'A')

$ python a.py
Exception: Unknown TLD: ca
(all known TLD: ['co', 'it', 'cz', 'at', 'eu', 'ru', 'lv', 'nz', 'net', 'pl', 
'be', 'fr', 'de', 'jp', 'me', 'co_jp', 'biz', 'org', 'info', 'name', 'us', 
'uk', 'com'])

Original issue reported on code.google.com by sta...@wm4d.com on 5 Oct 2014 at 4:21

DannyCork commented 6 years ago

Thanks for raising this.

Currently, .ca isn't supported.It's on the todo list.

nixawk commented 6 years ago
# -*- coding: utf-8 -*-

import whois

new_tld = {
    'ca': {
        'creation_date': re.compile('Creation Date:\\s?(.+)', re.IGNORECASE),
        'domain_name': re.compile('Domain Name:\\s?(.+)', re.IGNORECASE),
        'emails': re.compile('[\\w.-]+@[\\w.-]+\\.[\\w]{2,4}', re.IGNORECASE),
        'expiration_date': re.compile('Expiration Date:\\s?(.+)', re.IGNORECASE),
        'name_servers': re.compile('Name Server:\\s*(.+)\\s*', re.IGNORECASE),
        'registrant': None,
        'registrar': re.compile('Registrar:\\s?(.+)', re.IGNORECASE),
        'status': re.compile('Domain Status:\\s?(.+)', re.IGNORECASE),
        'updated_date': re.compile('Updated Date:\\s?(.+)', re.IGNORECASE)
        }
    }

whois.TLD_RE.update(new_tld)

domain = 'invisiblebracesintoronto.ca'
response = whois.query(domain, 'A')
DannyCork commented 3 years ago

.ca working

import whois domain = whois.query('invisiblebracesintoronto.ca') print(domain.dict) {'name': 'invisiblebracesintoronto.ca', 'registrar': 'Go Daddy Domains Canada, Inc', 'registrant_country': 'REDACTED FOR PRIVACY', 'creation_date': datetime.datetime(2013, 10, 4, 16, 27, 42), 'expiration_date': datetime.datetime(2021, 10, 4, 16, 27, 42), 'last_updated': datetime.datetime(2020, 11, 18, 16, 33, 19), 'status': 'clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited', 'statuses': ['clientTransferProhibited https://icann.org/epp#clientTransferProhibited', 'clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited', 'clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited'], 'dnssec': False, 'name_servers': {'dns1.stabletransit.com', 'dns2.stabletransit.com'}}