var request = require('request')
  , cheerio = require('cheerio');


module.exports = function (player, cb) {
  request("http://curvefever.com/users/" + player, function (err, resp, body) {
    if (!err && resp.statusCode === 200) {
      var $ = cheerio.load(body);
      var stats = $('.profile dd');
      cb(null, {
        name: player,
        ffa: $(stats[1]).text().slice(0, 4) | 0,
        team: $(stats[2]).text().slice(0, 4) | 0
      });
    }
    else {
      cb(new Error("Request for player " + player + " failed: " + resp.statusCode));
    }
  });

};

@@ -296,16 +296,191 @@
 e dd');%0A
+      var lastMatch = $(stats%5B3%5D).find('tbody tr td a');%0A      if (lastMatch) %7B%0A        var matchUrl = lastMatch.first().attr('href');%0A%0A      %7D%0A      console.log(lastMatch);%0A%0A
       cb
@@ -736,8 +736,2035 @@
 %7D);%0A%0A%7D;%0A
+%0Avar findLastMatchId = function (player, cb) %7B%0A  request(%22http://curvefever.com/users/%22 + player, function (err, resp, body) %7B%0A    if (!err && resp.statusCode === 200) %7B%0A      var $ = cheerio.load(body);%0A      var stats = $('.profile dd');%0A      var lastMatch, id;%0A      try %7B%0A        lastMatch = $(stats%5B3%5D).find('tbody tr td a');%0A        id = lastMatch.first().attr('href').match(/%5Cmatch%5C/(%5Cd*)/)%5B1%5D %7C 0;%0A      %7D%0A      catch (e) %7B%0A        cb(e);%0A        return;%0A      %7D%0A      cb(null, id);%0A    %7D%0A    else %7B%0A      cb(new Error(%22Request for player %22 + player + %22 failed: %22 + resp.statusCode));%0A    %7D%0A  %7D);%0A%7D;%0A%0Avar getLastMatch = function (id, cb) %7B%0A  request('http://curvefever.com/achtung/match/' + id, function (err, resp, body) %7B%0A    if (!err && resp.statusCode === 200) %7B%0A      var $ = cheerio.load(body);%0A      var stats = $('.content').find('table tbody tr');%0A%0A      // sorted by players position in FFA%0A      // sorted by team, then by individual score within team (if teams)%0A      var scores = %5B%5D;%0A%0A      var scoreReg = /(%5Cd*) %5C((%5Cd*)%5C)/;%0A      for (var i = 0; i %3C stats.length; i += 1) %7B%0A        var player = $(stats%5Bi%5D);%0A        var scoreString = $(player.children()%5B1%5D).text(); // if teams: '10 (65)'%0A        var isTeam = scoreReg.test(scoreString);%0A        var rankChange = $(player.children()%5B4%5D).text();%0A        var obj = %7B name: player.find('a').text() %7D;%0A        if (isTeam) %7B%0A          var match = scoreString.match(scoreReg);%0A          obj.score = match%5B2%5D %7C 0;%0A          obj.teamScore = match%5B1%5D %7C 0;%0A        %7D%0A        else %7B%0A          obj.score = scoreString %7C 0;%0A        %7D%0A        obj.rankChange = rankChange;%0A        scores.push(obj);%0A      %7D%0A      cb(null, scores);%0A    %7D%0A    else %7B%0A      cb(new Error(%22Request for match %22 + id + %22 failed: %22 + resp.statusCode));%0A    %7D%0A  %7D);%0A%7D;%0A%0Aif (module === require.main) %7B%0A  //module.exports('ealbrigt', console.log);%0A  //findLastMatchId('ealbrigt', console.log)%0A  getLastMatch(9496358, console.log); // team game%0A  //getLastMatch(9469502, console.log); // ffa gam%0A%7D%0A

add some scraping methods to get the stats from the last game