How to get Google Page-Rank from Perl Script


Today got good package by which directly we can get the google page rank.

This is the easiest way to find the google page rank from Perl Code.

I tried this code in 2 ways
1. By list in the code
2. By putting the site from command prompt.

#!/usr/bin/perl
use warnings;
use strict;

use WWW::Google::PageRank;
my $pr = WWW::Google::PageRank->new;

my $page = $ARGV[0];

my @sites = (
  'http://www.yahoo.com',
  'http://www.wordpress.org',
  'http://www.wordpress.com',
  'http://www.labnol.org'
);
if(!$page) {
  foreach(@sites) {
	  print "$_ : ";
	  print scalar($pr->get($_)), "\n";
  }
} else {
  print "$page : ";
  print scalar($pr->get($page)), "\n";
}

2 Ways to run this code

ankur@ankur:~> perl googlerank.pl
http://www.yahoo.com : 9
http://www.wordpress.org : 9
http://www.wordpress.com : 9
http://www.labnol.org : 6
ankur@ankur:~> perl googlerank.pl http://www.apple.com
http://www.apple.com : 9
ankur@ankur:~>

This is the simplest code, we can change based on requirement.

Happy Perl.

9 Comments

  1. xmcdeltatt
    Posted November 7, 2010 at 11:23 pm | Permalink | Reply

    Thank you for the information provided….

  2. Posted January 9, 2011 at 10:33 pm | Permalink | Reply

    Its really working. Thanks for nice code.

  3. Posted March 7, 2011 at 8:34 pm | Permalink | Reply

    its working great. and very fast then php code. thanks for it.

  4. Posted May 3, 2011 at 6:06 pm | Permalink | Reply

    this is really a nice stuff…. really appreciable work…

    keep posting more interesting this like that..!!!

  5. Posted May 9, 2011 at 3:50 pm | Permalink | Reply

    Thank You..Its Just amazing..great Yar…

  6. suresh
    Posted August 16, 2011 at 6:12 pm | Permalink | Reply

    super article. Great website. carry on.

  7. Posted October 25, 2011 at 12:04 pm | Permalink | Reply

    Use of uninitialized value in print at ./google.pl line 19.
    http://www.yahoo.com :
    Use of uninitialized value in print at ./google.pl line 19.
    http://www.wordpress.org :
    Use of uninitialized value in print at ./google.pl line 19.
    http://www.wordpress.com :
    Use of uninitialized value in print at ./google.pl line 19.
    http://www.labnol.org :

  8. Kelsey Jenney
    Posted September 30, 2012 at 10:12 am | Permalink | Reply

    Thanks for your advices. I will try it, and I hope I can get a better Page Rank as soon as possible. One of the most important things is, I must be consistent. Have a nice days… ^_^

  9. Morris
    Posted October 2, 2012 at 6:30 am | Permalink | Reply

    Incredible story there. What happened after?
    Take care!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: