|
Net::XWhois - Whois Client Interface for Perl5. |
Net::XWhois - Whois Client Interface for Perl5.
use Net::XWhois;
$whois = new Net::XWhois Domain => "vipul.net" ;
$whois = new Net::XWhois Domain => "bit.ch",
Server => "domreg.nic.ch",
Retain => 1,
Parser => {
nameservers => 'nserver:\s+(\S+)',
};
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.
(There is, however, a new standard called RPSL (RFC2622) used by RIPE (http://www.ripe.net), the European main whois server.)
To overcome this, Net::XWhois maintains another set of tables - parsing rulesets - for a few, popular response formats. (See %PARSERS). These parsing tables contain section names (labels) together with regular expressions that match the corresponding section text. The section text is accessed ``via'' labels which are available as data instance methods at runtime. By following a consistent nomenclature for labels, semantically related information encoded in different formats can be accessed with the same methods.
lookup() if a name is
provided. The argument hash can also specify a whois server, a parsing
rule-set or a parsing rule-set format. (See personality()). Omitting
the argument will create an ``empty'' object that can be used for accessing
class data.
Parser => {
name => 'domain:\s+(\S+)\n',
nameservers => 'nserver:\s+(\S+)',
contact_emails => 'e-mail:\s+(\S+\@\S+)',
};
Format => 'INTERNIC_CONTACT',
croak() if it can't connect to the whois server. The Error attribute
specifies a function call name that will be invoked when a network
connection error occurs. Possible values are croak, carp, confess (imported
from Carp.pm) and ignore (a blank function provided by Net::XWhois). You
can, of course, write your own function to do error handling, in which case
you'd have to provide a fully qualified function name. Example:
main::logerr.
register_parser() method.
Also see Data Instance Methods.
my %PARSERS = (
INTERNIC => {
contact_tech => 'Technical Contact.*?\n(.*?)(?=\...
contact_zone => 'Zone Contact.*?\n(.*?)(?=\s*\n[...
contact_billing => 'Billing Contact.*?\n(.*?)(?=\s*...
contact_emails => \&example_email_parser
},
{ etc. ... },
);
sub example_email_parser {
# Note that the default internal implemenation for
# the INTERNIC parser is not a user-supplied code
# block. This is just an instructive example.
my @matches = $_[0] =~ /(\S+\@\S+)/sg;
return @matches;
}
See XWhois.pm for the complete definition of %PARSERS.
my %WHOIS_PARSER = (
'whois.ripe.net' => 'RPSL',
'whois.nic.mil' => 'INTERNIC',
'whois.nic.ad.jp' => 'JAPAN',
'whois.domainz.net.nz' => 'GENERIC',
'whois.nic.gov' => 'INTERNIC',
'whois.nic.ch' => 'RIPE_CH',
'whois.twnic.net' => 'TAIWAN',
'whois.internic.net' => 'INTERNIC',
'whois.nic.net.sg' => 'RIPE',
'whois.aunic.net' => 'RIPE',
'whois.cdnnet.ca' => 'CANADA',
'whois.nic.uk' => 'INTERNIC',
'whois.krnic.net' => 'KOREA',
'whois.isi.edu' => 'INTERNIC',
'whois.norid.no' => 'RPSL',
( etc.....)
Please note that there is a plethora of output formats, allthough there are RFCs on this issue, like for instance RFC2622, there are numerous different formats being used!
my %DOMAIN_ASSOC = (
'al' => 'whois.ripe.net',
'am' => 'whois.ripe.net',
'at' => 'whois.ripe.net',
'au' => 'whois.aunic.net',
'az' => 'whois.ripe.net',
'ba' => 'whois.ripe.net',
'be' => 'whois.ripe.net',
register_parser()
my $w = new Net::Whois;
$w->register_parser (
Name => "INTERNIC",
Retain => 1,
Parser => {
creation_time => 'created on (\S*?)\.\n',
some_randome_entity => \&random_entity_subroutine
};
Instructions on how to create a workable random_entity_subroutine are availabe in the %PARSERS description, above.
register_association()
my $w = new Net::XWhois;
$w->register_association (
'whois.aunic.net' => [ RIPE, [ qw/au/ ] ]
);
register_cache()$w->register_cache ( "/some/place/else" ); $w->register_cache ( undef );
Internic Parser provides the following methods:
my $w = new Net::XWhois; $w->lookup ( Domain => "perl.com" ); print $w->response ();
Look at example programs that come with this package. ``whois'' is a replacement for the standard RIPE/InterNIC whois client. ``creation'' overrides the Parser value at object init and gets the Creation Time of an InterNIC domain. ``creation2'' does the same thing by extending the Class Parser. ``contacts'' queries and prints information about domain's Tech/Billing/Admin contacts.
contribs/ containts parsers for serveral whois servers, which have not been patched into the module.
Vipul Ved Prakash <mail@vipul.net>
Curt Powell <curt.powell@sierraridge.com>, Matt Spiers <matt@pavilion.net>, Richard Dice <rdice@pobox.com>, Robert Chalmers <robert@chalmers.com.au>, Steinar Overbeck Cook <steinar@balder.no>, Steve Weathers <steve@domainit.com>, Robert Puettmann <rpuettmann@ipm.net>, Martin H . Sluka`` <martin@sluka.de>, Rob Woodard <rwoodard15@attbi.com>, Jon Gilbert, Erik Aronesty for patches, bug-reports and many cogent suggestions.
Net::XWhois development has moved to the sourceforge mailing list, xwhois-devel@lists.sourceforge.net. Please send all Net::XWhois related communication directly to the list address. The subscription interface is at: http://lists.sourceforge.net/mailman/listinfo/xwhois-devel
RFC 954 <http://www.faqs.org/rfcs/rfc954.html> RFC 2622 <http://www.faqs.org/rfcs/rfc2622.html>
Copyright (c) 1998-2001 Vipul Ved Prakash. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Net::XWhois - Whois Client Interface for Perl5. |