Java, 540 chars
Warning: the number of active bounties is ~470. This code will access a page on stackoverflow that many times. It may get you in trouble with them for making so many data requests.
import java.io.*;import java.net.*;public class B{public static void main(String[]A){String u="http://stackoverflow.com/questions",d;Long i,s=i=0L,n=i.parseLong(o(u).replaceAll("^.*b.>(\\d+).*$","$1"));while(i++<n){d=o(u+"?pagesize=1&sort=featured&page="+n).replaceAll("^.*ion.>.(\\d+).*$","$1");s+=d.matches(".*\\D.*")?0:n.parseLong(d);}System.out.print(s);}static String o(String s){String d="";try{BufferedReader r=new BufferedReader(new InputStreamReader(new URL(s).openStream()));while((s=r.readLine())!=null)d+=s;}finally{return d;}}}
My output was 23400
, but when I ran @TonyH's code, I got 37550
. Bad news.
Pretty code:
import java.io.*;
import java.net.*;
public class StackOverflowBounty {
public static void main(String[] args) {
String u = "http://stackoverflow.com/questions", d;
Long i, s = i = 0L, n = i.parseLong(o(u).replaceAll("^.*b.>(\\d+).*$", "$1"));
while (i++ < n) {
d = o(u + "?pagesize=1&sort=featured&page=" + n).replaceAll("^.*ion.>.(\\d+).*$", "$1");
s += d.matches(".*\\D.*") ? 0 : n.parseLong(d);
}
System.out.print(s);
}
static String o(String s) {
String d = "";
try {
BufferedReader r = new BufferedReader(new InputStreamReader(new URL(s).openStream()));
while ((s = r.readLine()) != null) {
d += s;
}
} finally {
return d;
}
}
}
The way this works is simple. It reads from the url http://stackoverflow.com/questions"
to determine the number of questions that have bounties (note: if the number increases, the program fails, but if it drops, it works fine). It searches for this number using the regex: b.>(\\d+)
. This has worked in all tests to date, but if someone asked a question that matches that regex, this might not work.
Then, we open the url http://stackoverflow.com/questions?pagesize=1&sort=featured&page=
+ current question #
. In other words, we open a new page for each featured question, and force the number of questions to be only 1
, so we will get them all. The reputation part will always match ion.>.(\\d+)
, so I use that to find it. I split the operation into two parts so that I could cheaply check if the number of questions reduced (ie the string returned is not an integer).
Then, we sum up all the reputation and print it.
It took about 3 minutes and 20 seconds to run on my machine.
Does anyone know why it isn't printing the right number?