Check Google PageRank for multiple pages
One of the many incredibly useful modules over at the Perl module database CPAN, is the WWW::Google::PageRank module. It gives a quick and easy way of checking PageRank for a number of pages without delving into the particulars of the header exchanges over at toolbarqueries.google.com.
In order to use the script below, first create a file named 'pages.txt', and enter the full URLs of the pages you want to check, separated by newline characters, and save it in the same directory as the script:
-
#!/usr/bin/perl -w
-
use strict;
-
use warnings;
-
use Getopt::Std;
-
use File::Basename;
-
use WWW::Google::PageRank;
-
-
-
my $pr = WWW::Google::PageRank->new;
-
-
my %opts;
-
getopts('uhsd:', \%opts);
-
my $urlfile = 'pages.txt';
-
&usage if ($opts{'u'} || $opts{'h'});
-
my $urls = get_urls($urlfile);
-
-
if ($opts{'s'}) {}
-
if ($opts{'d'}) {
-
} else {
-
}
-
}
-
-
# Subroutine to fetch URLs from 'pages.txt' file
-
sub get_urls {
-
my %urls;
-
-
while(<URLS>) {
-
my $url;
-
next if /^#/;
-
$url = $1;
-
unless($url =~ '^http://') {
-
$url = 'http://' . $url;
-
}
-
$urls{$url} = 0;
-
}
-
close URLS;
-
return \%urls;
-
}
-
close PRANK;
When you run the script at the command line ('perl script.pl'), it will generate a Comma Separated file with PageRank values next to each relevant URL.







