POE::Component::Client::Whois::Smart - Provides very quick WHOIS queries with smart features.
POE::Component::Client::Whois::Smart provides a very quick WHOIS queries with smart features to other POE sessions and components. The component will attempt to guess the appropriate whois server to connect to. Supports cacheing, HTTP-queries to some servers, stripping useless information, using more then one local IP, handling server's bans.
use strict; use warnings; use POE qw(Component::Client::Whois::Smart); my @queries = qw( google.com yandex.ru 84.45.68.23 REGRU-REG-RIPN ); POE::Session->create( package_states => [ 'main' => [ qw(_start _response) ], ], ); $poe_kernel->run(); exit 0; sub _start { POE::Component::Client::Whois::Smart->whois( query => \@queries, event => '_response', ); } sub _response { my $all_results = $_[ARG0]; foreach my $result ( @{$all_results} ) { my $query = $result->{query} if $result; if ($result->{error}) { print "Can't resolve WHOIS-info for ".$result->{query}."\n"; } else { print "QUERY: ".$result->{query}."\n"; print "SERVER: ".$result->{server}."\n"; print "WHOIS: ".$result->{whois}."\n\n"; }; } }
Creates a POE::Component::Client::Whois session. Takes two mandatory arguments and a number of optional:
query is an arrayref of domains, IPs or registaras to send to whois server. Required.
The event name to call on success/failure. Required.
A session or alias to send the above 'event' to, defaults to calling session. Optional.
Specify server to connect. Defaults try to be determined by the component. Optional.
Optional.
0 - make just one query, do not follow if redirections can be done;
1 - follow redirections if possible, return last response from server; # default
2 - follow redirections if possible, return all responses;
Exapmle:
#... POE::Component::Client::Whois->whois( query => [ 'google.com', 'godaddy.com' ], event => '_response', referral => 2, ); #... sub _response { my $all_results = $_[ARG0]; foreach my $result ( @{$all_results} ) { my $query = $result->{query} if $result; if ($result->{error}) { print "Can't resolve WHOIS-info for ".$result->{query}."\n"; } else { print "Query for: ".$result->{query}."\n"; # process all subqueries my $count = scalar @{$result->{subqueries}}; print "There were $count subqueries:\n"; foreach my $subquery (@{$result->{subqueries}}) { print "\tTo server ".$subquery->{server}."\n"; # print "\tQuery: ".$subquery->{query}."\n"; # print "\tResponse:\n".$subquery->{whois}."\n"; } } } } #...
0 - give the whole response.
1 - attempt to strip several known copyright messages and disclaimers.
2 - will try some additional stripping rules if some are known for the spcific server.
Default is 2;
Use whois-servers.net to get the whois server name when possible. Default is to use the hardcoded defaults.
Cancel the request if connection is not made within a specific number of seconds. Default 30 sec.
List of local IP addresses to use for WHOIS queries.
Whois information will be cached in this directory. Default is no cache.
Number of minutes to save cache. 1 minute by default.
If exceed_wait true, will wait for for 1 minute and requery server in case if your IP banned for excessive querying. By default return 'Connection rate exceeded' in $result->{error};
ARG0 will be an array of hashrefs, which contains replies. See example above.
Sergey Kotenko <graykot@gmail.com>
This module is based on the Net::Whois::Raw http://search.cpan.org/perldoc?Net::Whois::Raw and POE::Component::Client::Whois http://search.cpan.org/perldoc?POE::Component::Client::Whois
RFC 812 http://www.faqs.org/rfcs/rfc812.html.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install POE::Component::Client::Whois::Smart, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::Client::Whois::Smart
CPAN shell
perl -MCPAN -e shell install POE::Component::Client::Whois::Smart
For more information on module installation, please visit the detailed CPAN module installation guide.