I wanted to write a small program to automatically alert me if certain domain
names became available to register. My first thought was to write a Bash script
to run the
whois command and parse the output with a combination of
Grep and Sed, but after looking at the mess that
whois returns, I
opted to go another route.
I found a Python module to retrieve WHOIS
data and installed it with
pip install whois. I played around it for a few minutes and
realized that while the website mentions support for .net addresses, the .net
domain wasn’t actually coded into the module. Luckily, the data returned by
whois is in the same format for both .net and .com domain names. I
added the following few lines to
/usr/lib/python3.2/site-packages/whois/tld_regexpr.py and it
started to work fine.
I wanted to have the script only output something when a domain name was close to being expired so that it could be easily installed into a cron job. The final script is here:
This script works perfectly for me. I set up cron to run it daily, so whenever one of the domains I’m watching comes close to being available, I’ll get an email notification.