Recently I was looking for a new domain name for a niche I was researching – being an old hand at using CPAN I looked for a module that would tell me whether a domain name was available for purchase… I tried a plugin that was for a specific registrar but I couldn’t get a login to their API.
So – wanting a quick solution (just for myself) I went looking at some of my old source code looking for a possible solution. I had written code in the past to get domain names from IP addresses so I played with that for a little bit and came up with a quick solution.
#!/usr/bin/perl -w use strict; use Net::Nslookup; my $name = nslookup( host => "$ARGV[0]", type => "A"); print "$ARGV[0] "; if ( not defined($name) ) { print "appears to be available"; } else { print "appears to be taken"; } print "n";
It uses Net::Nslookup which I had used on a past project when I was working with Apache access log files.
It doesn’t seem like it should work but it does – I’ve played with it quite a bit and haven’t seen a case yet where it didn’t work properly. Of course your mileage may vary.
Afterwards I wrote a wrapper script that called it that checked the .com, .net, and .org for whatever text you had written in to search for. I leave that as an exercise for the reader.
Of course, ten minutes after I wrote this I found a domain it didn't work for – it was registered but had no DNS 'A' record. I'm thinking about writing something to run a whois command for a domain looking for "No match for" but I'll have to do some research. Back to CPAN is probably my next step. Oh, well.