Rank checking on Google’s SERPs

Since everyone else seems to be releasing free/not quite free Google SERP ranking trackers, in the spirit of "what the hell they'll change the code tomorrow anyway", here's the (Perl) regular expression I've been using for my own Google SERP tracker:

PERL:
  1. while ($content =~ m{<div class=g(?:[^>]*?)><!--m-->(?:.*?)<h2 class=r><a href="([^"]*?)" class=l onmousedown="return (?:clk|rwt)\(this(?:\.href)?,'[^']*','[^']*','res','(\d+)','[^']*'(?:,'[^']*')?\)">(.*?)</a>.*?</h2>.*?<(?:font size=-1|div class=(?:sml|std))>(?:((?:\w|<b>).*?)<br>.*?)?<span class=a>(.*?)</span>(?:<nobr>)?(?:<a class=fl href="([^"]*?)"(?:[^>]*?)>Cached</a> - )?(?:<a class=fl href="([^"]*?)">Similar pages</a>)?(?:</nobr>)?(.*?)</(?:font|div)>.*?<!--n-->}gi) {}

Of course it's up to you to figure out the rest of the code surrounding the regex :)

Will Google ever stop this madness by actually creating a decent API to their results pages?

Update: Aargh - thanks to Wordpress's impossible handling of smart-quotes, that code is broken by the smart quotes peppered throughout it - do a search and replace to fix that...

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • StumbleUpon
  • Technorati
  • E-mail this story to a friend!

Tags: , , ,

2 Responses to “Rank checking on Google’s SERPs”

  1. Eric Giguere Says:

    Actually, I haven’t yet decided if I’ll charge for my tool or not. It’s free for now, at least :-)

    Fun what you can do with regular expressions.

    Eric
    aka “The Toolinator”

  2. rob Says:

    Very true - your link text has now been swapped around with Joost’s, which is charged for ;)

Leave a Reply