Saturday, January 24, 2009

Retrieve the search rank for your blog automatically

I was reading the latest article over at Pretty Your Blog yesterday and it gave me an idea for a first script. The FileInfo program that I wanted to present is already written and I may come back to it later. The RankSearch project that I have in mind will be written from the ground up so you'll be able to monitor the progress as I crawl towards completion. I hope you'll pitch in as well!

RankSearch: The need
Kelly wrote in Pretty Your Blog:
I ran another (unofficial) experiment; I did a google search for frugal blog. And the result? Almost Frugal was on the 13th page of search results.
It is very likely that Kelly clicked on the next link at the bottom of each Google page until she found her blog's reference (by the way, if you are interested in improving your blog, you may want to visit Pretty Your Blog often :).
What if we could write a Perl script that automatically returns the Google rank based for any URL on a given keyword? That's the idea behind

RankSearch: The specifications
The script will have to be as generic as possible and would take 3 input parameters:
- Search engine URL (eg: "" or "")
- URL of the blog you want to check the ranking for (eg: "")
- The search criteria you are investigating (eg: "frugal blog")

The output result will be a simple message of the type: is ranked 7th on the google search engine for the "frugal blog" criteria.

It will run on Windows and Linux environments
Do you see anything else to add?

And here is the template for it:
#!/usr/bin/perl -w
# ----------------------------------------
# File :
# Author : DLP
# Date : January 24th 2009
# Object : Looks in a search engine what is the rank
# for a given website and a given keyword
# Input : - Search engine URL, eg. ""
# - URL of website to monitor
# - Search expression to investigate
# Bugs : None
# To do : - Read input and store in script variable
# - Launch http request
# - Read html result
# - Analyse result and display website rank
# ----------------------------------------
use strict;

my $PROG_NAME = "RankSearch";
my $VERSION = "v0.0.1";
my $PROG_DATE = "January 24th 2009";

print "$PROG_NAME $VERSION from $PROG_DATE.\n";

Jan 24 2009: first version of RankSearch

French word of the day:
"économe": frugal

New posts:
  • Our first Perl program - Part II: parsing the Perl command line
  • More about CPAN
  • Our first Perl program - Part III: Launch a HTTP request
  • How to install Google Analytics on your Blogger blog
  • Our first Perl program - Part IV: Read results from a HTML page
  • Perl help resources
  • Our first Perl program - Part V: Result analysis
  • Our first Perl program - Part VI: Add a GUI interface


  1. Before you decide to name your program 'SearchRank' I'd like to bring to your attention that SearchRank is the federally registered trademark of my company, a trademark that we defend vigorously.

    I'd therefore advise you to rethink what you will call your project as it would violate our trademark.

    Please email me at legal at to advise what your response is so I know what my next actions are.

  2. This is funny which part of the searchrank is trademarked? The search or the rank?

    You can not trademark it and if you did, you have no chance whatever.

    By the way, seen several such modules on CPAN.


  3. @Moshe - Neither 'search' nor 'rank' but the two words together (SearchRank). And if you don't believe it is trademarked, see for yourself -

    @Damien - Thanks for your cooperation.

  4. "to advise what your response is so I know what my next actions are..."

    What, litigation? You've got to be kidding me...that was an extremely threatening comment to leave on a guy's blog who is just trying to teach others about PERL.

    I certainly know where I won't be taking my business for search engine help.