たまに空ドメインを探す為に、Whois検索を行います。
Shellで用は足りますが、Perlから使う方法は無いかと思い少し調べました。
要件は、JPドメインの検索が出来ること。出力形式のカスタマイズが出来ること。
さくっと使えること←(私にとって)
何も考えずにCPAN Search。
ざっと見たところ候補は、
Net::Whois - Get and parse "whois" domain data from InterNIC DESCRIPTION Net::Whois::Domain new() attempts to retrieve and parse the given domain's "whois" information from the InterNIC (whois.internic.net). If the server could not be contacted, is too busy, or otherwise does not process the query then the constructor does not return a reference and your object is undefined. If the constructor returns a reference, that reference can be used to access the various attributes of the domains' whois entry assuming that there was a match. The member function ok returns 1 if a match 0 if no match. Note that the Locale::Country module (part of the Locale-Codes distribution) is used to recognize spelled-out country names; if that module is not present, only two-letter country abbreviations will be recognized. The server consulted is "whois.internic.net". You can only get .org, .edu, .net, .com domains from Internic. Other whois servers for other Top-Level-Domains (TLD) return information in a different syntax and are not supported at this time. Also, only queries for domains are valid. Querying for a network will fail utterly since those are not kept in the whois.internic.net server (a future enhancement will add a network lookup function). Querying for NIC handles won't work since they have a different return syntax than a domain. Domains other than those listed won't work they're not in the server. A future enhancment planned will send the query to the appropriate server based on its TLD.
恐らく一番最初のwhois検索用モジュール。
jpドメイン見てくれないので、却下。
Net::Whois::Proxy - an easy to use recursive whois client library DESCRIPTION The Net::Whois::Proxy library is an easy to use recursive whois client library that does not do any additional parsing of the whois data. It's goal is to quickly track down domain, ipv4, ipv6, and BGP Anonymous System numbers.
Net::Whoisの簡易版。
上と同じ理由で却下。
Net::Whois::RIPE - implementation of RIPE Whois. DESCRIPTION Net::Whois::RIPE class implementing a RIPE whois client.
あっさりした説明。
参照先ホストも指定出来るので、要件は満たしている。
また、気に入らなければクラスを足せば良さそう。
Net::XWhois - Whois Client Interface for Perl5. DESCRIPTION The Net::XWhois class provides a generic client framework for doing Whois queries and parsing server response. The class maintains an array of top level domains and whois servers associated with them. This allows the class to transparently serve requests for different tlds, selecting servers appropriate for the tld. The server details are, therefore, hidden from the user and "vipul.net" (from InterNIC), gov.ru (from RIPE) and "bit.ch" (from domreg.nic.ch) are queried in the same manner. This behaviour can be overridden by specifying different bindings at object construction or by registering associations with the class. See "register_associations()" and "new()". One of the more important goals of this module is to enable the design of consistent and predictable interfaces to incompatible whois response formats. The Whois RFC (954) does not define a template for presenting server data; consequently there is a large variation in layout styles as well as content served across servers.
これも要件を満たしている。
Net::Whois::RIPEより簡単に使えるので、今回はこれを採用。
中身を見たら、whoisサーバがつらーっと記述されていたりして何だかなぁという
気はするが、確かに便利は便利。
Googleでのヒット件数もこちらの方が多かったので、よく使われているのかな?
使い方は、また次回。