Latest version: whois 0.2.0.

Purpose and principle

The original purpose was to find the country of spam posters on my blog. To do this it is possible to use some free IP/country databases that work quite good. The drawback is that they need frequent updates so that the need to query online whois services appeared.

The first release 0.1.0 of this whois Python package can guess an IP address country by:

  1. searching local IP/country databases
  2. querying Internet whois servers

Previous searches are stored in a local database so that next time they are submitted the answer is quickly found. Note that this may be not very effective if you perform a lot of requests with different IP each time.


The source archive provides the standard Python installer (python install) as the development archive provides additional files to build documentation, archives and Windows installer. You can check file integrity using the following MD5 sums:

7a793445033862b1aeba348caa037fb5  whois-0.1.0.tar.gz
bafb0dfa9421a31a523ce9d36a1fe44c  whois-0.1.0.win32.exe
df71447ba411901e7732712866037d6e  whois-dev-20070326.tar.bz2


Uncompress the archive and install the Python module as root:

# tar xzf whois-0.1.0.tar.gz
# cd whois-0.1.0/
# python install

You're done! If you don't have administrator rights, just keep the uncompressed directory in one of your personal folders and use the PYTHONPATH variable to let Python find it. Alternatively Windows users may prefer the installation executable but it has never been tested...[1]

Additional IP/country databases or updates can be downloaded from:

A copy from the first database source is included in the Python module. Its date stamp is 2007-03-24.


Querying an IP country is quite straightforward:

>>> import whois
> loaded 79552 IP ranges from /usr/lib/.../whois/db/IpToCountry.csv.db
>>> print whois.guessIPcountry('')

Full Internet whois query is a bit more complicated:

>>> Whois = whois.WhoisConsumer('')
>>> whois.WhoisRequest(Whois, '', whois.WhoisServer)
<whois._whois.WhoisRequest at -0x4a62ce74>
>>> whois.asyncore.loop()
>>> print Whois.text


[1] sorry I don't care of Windows any more