Checking if a domain name is registered

只愿长相守 提交于 2019-11-30 03:38:27
Thomas

"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.

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.

use the net_whois package from pear. for multiple results, which may occur when server names are also reported along with domain names do something similar to:

require_once ¨Net/Whois.php¨;
$whois = new Net_Whois;
$whois->authorative = true;
$data = $whois->query(¨example.com¨);

To check if a domain name is registered you need two informations:

  • The whois server for the respective top level domain (or second level domain)
  • A matching pattern for the response of that whois server

Those informations do change frequently. This Whois Server list tries to compile the needed informations for more than 500 top level domains. The list also offers an API service to check if a domain is available. The PHP client for that API would be whois-api-php:

$whoisApi = new whoisServerList\WhoisApi("apiKey");
echo $whoisApi->isAvailable("example.net") ? "available" : "registered";
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!