Make a codegolf scorer You are to make a program that given a number, such as 22009, will go for example to Pi Calculation Code Golf. Then it will, for each answer, try to figure out what the code is, and count its characters. It will then output, for each answer, its number of characters, and a link to it. It should be sorted with fewest characters at the top. For example :


$ answers 22009
5 https://codegolf.stackexchange.com/a/22138/16842
5 https://codegolf.stackexchange.com/a/22188/16842
6 https://codegolf.stackexchange.com/a/22012/16842
6 https://codegolf.stackexchange.com/a/22043/16842

and so on



This is code-golf, so shortest code wins!

Note: If there are multiple things that look like code blocks, it doesn't matter which you choose. It is better though if you look which block actually looks like a program, or you could post a different one for each block.

Note: This specifically says characters. It does not matter what the question actually says, just count characters.
Perl - 233

use LWP::Simple;for($s="http://codegolf.stackexchange.com",$h=get"$s/questions/@ARGV";$h=~/-answerid="(\d+).+?(&lt;div id="answer-|$)/sg;){$a=$&amp;;$i=$1;$_=$1,$_=~s/&amp;.+?;/@/sgm,print length."$u\t$s/a/$i/\n"while$a=~/&lt;pre&gt;&lt;code&gt;(.+?)&lt;/sg;}


More aerated version:

use LWP::Simple;
$s="http://codegolf.stackexchange.com";
$h=get"$s/questions/@ARGV";
for(;$h=~/-answerid="(\d+).+?(&lt;div id="answer-|$)/gs;){
    $a=$&amp;;
    $i=$1;
    while($a=~/&lt;pre&gt;&lt;code&gt;(.+?)&lt;/gs){
        $_=$1;
        $_=~s/&amp;.+?;/@/sgm;
        print length."$u\t$s/a/$i/\n"
    }
}


This is my first script in this language... so there's still probably a lot of golfing to do.