Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking if a domain name is registered

How would I go about checking if a domain name is registered? I was thinking about checking if it has a corresponding IP but it doesn't seem to work as well as I had hoped. Is there a solution in either PHP or Python that can check?

like image 296
Evan Fosmark Avatar asked Nov 08 '09 19:11

Evan Fosmark


2 Answers

"Registered" doesn't mean "assigned an IP address". To know whether a domain name is registered, you'll need to do a whois query.

For Python, there's pywhois, but from its web site it seems somewhat immature. Also see this SO question.

For PHP, there's... surprise... phpwhois.

like image 185
Thomas Avatar answered Oct 11 '22 03:10

Thomas


Mike Nott has created a simple PHP class that allows you to query the who.is data for any domain you wish.

Once you call

    $whois = getwhois($sld, $tld);

you then just need to check the contents of $whois to determine whether the domain is currently registered.

like image 40
ConroyP Avatar answered Oct 11 '22 03:10

ConroyP