Eiko Wagenknecht
Software Developer, Freelancer & Founder

Finding Available Domains with a Python Script

Eiko Wagenknecht

This post is also available in German

A small Python 3 script that helps determine which domains are still available.

Table of Contents

Why This Project?

I recently had the idea to set up a catch-all email address for online service registrations, using a unique email address for each service. This way, if there’s a data leak, I can see where it came from and, more importantly, selectively block compromised addresses.

Ideally, I’d like to have addresses like [email protected] and [email protected]. For this purpose, having a short domain name would be great. Of course, example.com is already taken, but perhaps there’s something else available with just a few letters?

But how do you find this out? There are countless websites where you can check if a specific name is already taken, but to systematically find available domains, this approach is far too cumbersome. Fortunately, there’s a service designed for exactly this purpose: WHOIS.

The following script is what I came up with. It’s certainly not a model example of clean programming, but it does exactly what I want: Find all available .de domains with a maximum of 5 characters before the dot.

It uses Python’s “whois” package, which throws an exception when an entry doesn’t exist - exactly what we need. Since this involves quite a lot of queries, the WHOIS server eventually starts returning empty responses. That’s why I built in a small waiting function that keeps retrying in these cases. First after 2 seconds, then 4 seconds, 8 seconds, etc., as we don’t want to unnecessarily spam the server.

The results are displayed live in the console for each domain checked, and a list of all found available domains is saved in a text file.

If you’re also searching for a domain: Have fun with it 🙂

You can download the script from GitHub: https://github.com/eikowagenknecht/whois

To run it, you need to have Python 3 installed and the whois package installed via pip install python-whois. Then you can save the script and run it with python ./runthis.py.

Results (As of October 2021)

Only domains consisting exclusively of letters a-z are considered.

Available 1-character .de domains: 0 out of 26 (0%)

Available 2-character .de domains: 0 out of 676 (0%)

Available 3-character .de domains: 0 out of 17576 (0%)

Available 4-character .de domains: 49694 out of 456976 (10.87%)

Sources

https://stackoverflow.com/questions/31597125/how-to-find-out-programmatically-if-a-domain-name-is-registered-or-not

https://stackoverflow.com/questions/5419389/how-to-overwrite-the-previous-print-to-stdout-in-python

No Comments? No Problem.

This blog doesn't support comments, but your thoughts and questions are always welcome. Reach out through the contact details in the footer below.

Support Me

If you found this page helpful and want to say thanks, I would be very grateful if you could use this link for your next purchase on amazon.com. I get a small commission, and it costs you nothing extra. If you'd like to support me in another way, you can find more options here.