#!/usr/bin/perl -w

use strict;

my %pageRankURLs = ('http://justinblanton.com' => '61892415876');

my $kRequestURLTemplate = 
'http://www.google.com/search?client=navclient-auto&ch=%s&features=Rank&q=info:%s';

print <<HEADER;
Content-type: text/xml

<?xml version="1.0" ?>
<!-- RSS generated by pagerank2rss 1.0 -->
<rss version="2.0">
	<channel>
		<title>Justin Blanton PageRank</title>
		<link></link>
		<ttl>30</ttl>
HEADER
foreach my $pageRankURL (keys %pageRankURLs)
{
	my $pageRankRequestURL = sprintf($kRequestURLTemplate, 
$pageRankURLs{$pageRankURL}, $pageRankURL);
	open(CURL, "curl -s \"$pageRankRequestURL\"|") or die("can't 
launch curl");
	
	my $pageRank = 'Not found';
	
	while (<CURL>)
	{
		chomp;
		
		$pageRank = $1 if (/Rank_1:\d+:(\d+)/); # the first set of numbers is how many digits there are in the pagerank
	}
	
	close(CURL);
	
	print "<item><title>PageRank: $pageRank</title></item>\n";
}

print <<FOOTER;
	</channel>
</rss>
FOOTER
