
AnyEvent::Google::PageRank - Non-blocking wrapper for WWW::Google::PageRank

use AnyEvent::Google::PageRank;
use AnyEvent;
my @urls = qw(http://perl.org http://cpan.org http://perlmonks.org);
my $rank = AnyEvent::Google::PageRank->new(
timeout => 10,
proxy => 'localhost:3128'
);
my $cv = AnyEvent->condvar;
$cv->begin for @urls;
foreach my $url (@urls) {
$rank->get($url, sub {
my ($rank, $headers) = @_;
print "$url - ", defined($rank) ? $rank : "fail: $headers->{Status} - $headers->{Reason}", "\n";
$cv->end;
});
}
$cv->recv;
use AnyEvent::Google::PageRank qw(rank_get);
use AnyEvent;
my @urls = qw(http://perl.org http://cpan.org http://perlmonks.org);
my $cv = AnyEvent->condvar;
$cv->begin for @urls;
foreach my $url (@urls) {
rank_get $url, timeout => 10, proxy => 'localhost:3128', sub {
my ($rank, $headers) = @_;
print "$url - ", defined($rank) ? $rank : "fail: $headers->{Status} - $headers->{Reason}", "\n";
$cv->end;
};
}
$cv->recv;

AnyEvent::Google::PageRank helps to get google pagerank for specified url, like WWW::Google::PageRank does. But in contrast to WWW::Google::PageRank you can perform many requests in parallel. This module uses AnyEvent::HTTP as HTTP client.


Creates new AnyEvent::Google::PageRank object. The following options available (all are optional):
KEY DESCRIPTION DEFAULT ------------------------------------------------------------------ agent User-Agent value in the headers Mozilla/4.0 (compatible; GoogleToolbar 2.0.111-big; Windows XP 5.1) proxy http proxy as address:port undef timeout timeout for network operations AnyEvent::HTTP default timeout host host for query toolbarqueries.google.com ae_http AnyEvent::HTTP request options as hashref undef
Get rank for specified url and call specified callback on finish. Parameters for callback are: rank and headers. On fail rank will be undef and reason could be found in $headers->{Reason}, code in $headers->{Status}. Special codes provided by this module are:
695 - malformed url
For other codes see AnyEvent::HTTP

Get rank for specified url and call specified callback on finish. Key/value pairs are options understanded by AnyEvent::HTTP::http_request() and new() method of this module (except ae_http option). For $cb description see get() method.

Not a bug: don't forget to set $AnyEvent::HTTP::MAX_PER_HOST to proper value. See AnyEvent::HTTP for details.
If you find any bug, please report.

WWW::Google::PageRank, AnyEvent::HTTP

Copyright Oleg G <oleg@cpan.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.