AnyEvent-Google-PageRank

 view release on metacpan or  search on metacpan

lib/AnyEvent/Google/PageRank.pm  view on Meta::CPAN

sub get {
	my ($self, $url, $cb) = @_;
	
	croak 'Not a code reference in $cb'
		if ref($cb) ne 'CODE';
	
	return $cb->(undef, {Status => 695, Reason => 'malformed url'}) if $url !~ m[^https?://]i;
	
	my $ch = '6' . WWW::Google::PageRank::_compute_ch_new('info:' . $url);
	my $query = 'http://' . ($self->{host}||DEFAULT_HOST) . '/tbr?client=navclient-auto&ch=' . $ch .
		'&ie=UTF-8&oe=UTF-8&features=Rank&q=info:' . uri_escape($url);
	
	my $opts = {};
	if (ref($self) eq 'HASH') {
		# call from rank_get
		$opts = $self;
		$opts->{proxy}                 = [split /:/, $opts->{proxy}] if defined $opts->{proxy} && index($opts->{proxy}, ':') != -1;
		$opts->{headers}{'User-Agent'} = exists($opts->{agent}) ? $opts->{agent} : DEFAULT_AGENT;
	}
	else {
		# object call

t/2_rank.t  view on Meta::CPAN

				}
			
				my ($path) = $headers =~ /GET\s+(\S+)/
					or exit;
				
				$path =~ /ch=([^&]+)/
					or exit;
				
				my ($url) = $path =~ /info:(.+)/
					or exit;
				$url = uri_unescape($url);
				
				my $response;
				if (exists $table{$url}) {
					$response = $table{$url}[0];
					sleep $table{$url}[1];
				}
				else {
					$response = 'xxx';
				}
				



( run in 0.309 second using v1.01-cache-2.11-cpan-c21f80fb71c )