18.8. Using Whois to Retrieve Information from the InterNICProblem
You want to find out who owns a domain, as if you'd used the Unix SolutionUse the CPAN module Net::Whois: use Net::Whois; $domain_obj = Net::Whois::Domain->new($domain_name) or die "Couldn't get information on $domain_name: $!\n"; # call methods on $domain_obj to get name, tag, address, etc. DiscussionWhois is a service provided by domain name registration authorities to identify owners of domain names. Historically, queries were made with the whois (1) program on Unix systems, which returned about fifteen lines of information, including the names, addresses, and phone numbers of the administrative, technical, and billing contacts for the domain.
The
To request information on a domain, create a new Net::Whois::Domain object. For instance, to look up information on $d = Net::Whois::Domain->new( "perl.org" ) or die "Can't get information on perl.org\n"; The only guaranteed fields are the domain name and the tag - the domain's unique identifier in the NIC records: print "The domain is called ", $d->domain, "\n"; print "Its tag is ", $d->tag, "\n";
Information that may be present includes:
name
of the domain's company or product (e.g., " print "Mail for ", $d->name, " should be sent to:\n"; print map { "\t$_\n" } $d->address; print "\t", $d->country, "\n";
In addition to information about the domain, you can also get information on the domain's
contacts
. The $contact_hash = $d->contacts; if ($contact_hash) { print "Contacts:\n"; foreach $type (sort keys %$contact_hash) { print " $type:\n"; foreach $line (@{$contact_hash->{$type}}) { print " $line\n"; } } } else { print "No contact information.\n"; } See AlsoThe documentation for the Net::Whois module from CPAN; your system's whois (8) manpage (if you have one); RFC 812 and 954 |
|