If anyone wants to mess around with it...
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map.Entry;
public class DipTest {
public static String WON_STR = "Game won by";
public static String ELIMINATED = "line-through";
public static void main(String[] args) throws IOException {
HashMap<String, Integer> wins = new HashMap<String, Integer>();
HashMap<String, Integer> deaths = new HashMap<String, Integer>();
for (int pageNum = 1; pageNum <= 140; pageNum++) {
URL url = new URL("http://phpdiplomacy.net/gamelistings.php?gametype=Finished&page=" + pageNum);
URLConnection con = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line = in.readLine();
while (line != null) {
if (line.contains("gamemain")) {
// pot:
int start = line.indexOf("Pot: ");
start = line.indexOf('>', start) + 1;
int end = line.indexOf('<', start);
int pot = Integer.parseInt(line.substring(start, end));
//reset to 1 anyway
pot = 1;
//System.out.println(line);
if (line.contains(WON_STR)) {
int begIndex = line.indexOf(WON_STR);
start = line.indexOf('"', begIndex);
end = line.indexOf('"', start + 1);
String country = line.substring(start + 1, end);
if (wins.containsKey(country))
wins.put(country, (wins.get(country) + pot));
else
wins.put(country, pot);
}
if (line.contains("Game drawn")) {
if (wins.containsKey("Draws"))
wins.put("Draws", (wins.get("Draws") + pot));
else
wins.put("Draws", pot);
}
// now find the eliminated players
int index = 0;
while (index < line.length() && index >= 0) {
index = line.indexOf(ELIMINATED, index);
if (index < 0)
break;
index = line.indexOf(" as ", index);
start = index + 4;
end = line.indexOf('<', start);
String country = line.substring(start, end);
if (deaths.containsKey(country))
deaths.put(country, (deaths.get(country) + pot));
else
deaths.put(country, pot);
}
}
// next line
line = in.readLine();
}
System.out.print(pageNum + ", ");
}
System.out.println("\n\nWins:");
for (Entry<String, Integer> winNum : wins.entrySet()) {
System.out.println(winNum.getKey() + ": " + winNum.getValue());
}
System.out.println("\nDeaths:");
for (Entry<String, Integer> deathNum : deaths.entrySet()) {
System.out.println(deathNum.getKey() + ": " + deathNum.getValue());
}
}
}