README.rst
author Vanush Paturyan <ektich@gmail.com>
Wed, 13 Dec 2017 17:49:29 +0000
branchie_tld
changeset 156 9437303d43e8
parent 143 36a89acade53
child 177 7030835bcf5e
permissions -rw-r--r--
Add handling of .ie domains
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     1
Goal
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     2
====
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     3
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     4
-  Create a simple importable Python module which will produce parsed
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     5
   WHOIS data for a given domain.
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     6
-  Able to extract data for all the popular TLDs (com, org, net, ...)
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     7
-  Query a WHOIS server directly instead of going through an
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
     8
   intermediate web service like many others do.
79
95f170b4fd13 README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 78
diff changeset
     9
-  Works with Python 2 & 3
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    10
61
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    11
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    12
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    13
Example
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    14
=======
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    15
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    16
.. sourcecode:: python
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    17
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    18
    >>> import whois
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    19
    >>> w = whois.whois('webscraping.com')
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    20
    >>> w.expiration_date  # dates converted to datetime object
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    21
    datetime.datetime(2013, 6, 26, 0, 0)
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    22
    >>> w.text  # the content downloaded from whois server
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    23
    u'\nWhois Server Version 2.0\n\nDomain names in the .com and .net 
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    24
    ...'
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    25
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    26
    >>> print w  # print values of all found attributes
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    27
    creation_date: 2004-06-26 00:00:00
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    28
    domain_name: [u'WEBSCRAPING.COM', u'WEBSCRAPING.COM']
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    29
    emails: [u'WEBSCRAPING.COM@domainsbyproxy.com', u'WEBSCRAPING.COM@domainsbyproxy.com']
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    30
    expiration_date: 2013-06-26 00:00:00
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    31
    ...
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    32
61
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    33
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    34
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    35
Install
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    36
=======
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    37
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    38
Install from pypi:
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    39
79
95f170b4fd13 README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 78
diff changeset
    40
.. sourcecode:: bash
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    41
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    42
    $ pip install python-whois
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    43
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    44
Or checkout latest version from repository:
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    45
79
95f170b4fd13 README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 78
diff changeset
    46
.. sourcecode:: bash
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    47
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    48
    $ hg clone https://bitbucket.org/richardpenman/pywhois
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    49
79
95f170b4fd13 README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 78
diff changeset
    50
Note that then you will need to manually install the futures module, which allows supporting both Python 2 & 3:
78
9f5fac50355a README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 77
diff changeset
    51
9f5fac50355a README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 77
diff changeset
    52
9f5fac50355a README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 77
diff changeset
    53
.. sourcecode:: bash
9f5fac50355a README.rst edited online with Bitbucket
Richard Penman <richard.penman@gmail.com>
parents: 77
diff changeset
    54
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    55
    $ pip install futures
61
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    56
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    57
Run test cases for python 2 & 3:
77
df9f497129e8 updated log and version
Richard Penman
parents: 61
diff changeset
    58
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    59
.. sourcecode:: bash
61
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    60
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    61
    $ python -m unittest discover test
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    62
    .............
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    63
    ----------------------------------------------------------------------
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    64
    Ran 13 tests in 0.812s
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    65
    
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    66
    OK
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    67
    
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    68
    $ python3 -m unittest discover test
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    69
    .............
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    70
    ----------------------------------------------------------------------
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    71
    Ran 13 tests in 1.431s
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    72
    
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
    73
    OK
61
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    74
c391985a797b README.rst edited online with Bitbucket
Richard Penman <richardbp@gmail.com>
parents: 55
diff changeset
    75
131
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    76
Problems?
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    77
=========
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    78
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    79
Pull requests are welcome! 
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    80
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    81
Thanks to the many who have sent patches for additional TLDs. If you want to add or fix a TLD it's quite straightforward. 
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    82
See example domains in `whois/parser.py <https://bitbucket.org/richardpenman/pywhois/src/tip/whois/parser.py?at=default&fileviewer=file-view-default>`_
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    83
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    84
Basically each TLD has a similar format to the following:
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    85
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    86
.. sourcecode:: python
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    87
131
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    88
    class WhoisOrg(WhoisEntry):
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    89
    """Whois parser for .org domains
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    90
    """
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    91
    regex = {
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    92
        'domain_name':      'Domain Name: *(.+)',
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    93
        'registrar':        'Registrar: *(.+)',
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    94
        'whois_server':     'Whois Server: *(.+)',
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    95
        ...
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    96
    }
55
bc23472ae284 converted README from markdown to RST for pypi
Richard Penman
parents:
diff changeset
    97
131
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    98
    def __init__(self, domain, text):
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
    99
        if text.strip() == 'NOT FOUND':
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
   100
            raise PywhoisError(text)
193a62737030 README.rst edited online with Bitbucket
Richard <richardbp@gmail.com>
parents: 100
diff changeset
   101
        else:
143
36a89acade53 added test case example to readme
richardpenman
parents: 131
diff changeset
   102
            WhoisEntry.__init__(self, domain, text)