Checking .to (Tonga) Domain Availablility


Tue, 02 May 2017

The .to TLD is a very attractive one, however, automating the whois for it is somewhat a pain. It appears their public whois server is often down.

I've written this short Python snippet to check availability:

import urllib2


def is_available(name):
    response = urllib2.urlopen('https://www.tonic.to/whois?' + name)
    content = response.read()
    try:
        response.close()
    except Exception:
        pass
    if "No match for domain" in content:
        return True
    else:
        return False

To use it, simply call:

if is_available("foo") is True:
    print("Available")
else:
    print("Not available")

Pretty simple, but it does the job well.