Skip to content

Instantly share code, notes, and snippets.

@indexzero
Forked from chapel/arena
Created October 7, 2010 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save indexzero/614593 to your computer and use it in GitHub Desktop.
Save indexzero/614593 to your computer and use it in GitHub Desktop.
var httpAgent = require('http-agent'),
url = require('url'),
sys = require('sys');
exports.start = function () {
var agent = httpAgent.create('www.bungie.net', ['/stats/reach/playergamehistory.aspx?player=thechapel&vc=2']);
agent.addListener('next', function (err, agent) {
var uri = url.parse(agent.current.uri);
exports.dispatch(uri);
});
agent.addListener('stop', function (err, agent) {
sys.puts('the agent has stopped');
});
agent.start();
};
exports.dispatch = function (uri, agent) {
switch (uri.pathname) {
case '/stats/reach/playergamehistory.aspx':
exports.playergamehistory(agent);
break;
}
};
exports.playergamehistory = function (agent) {
var window = jsdom.jsdom(agent.body).createWindow();
jsdom.jQueryify(window, '/home/wyl/webapps/node/jquery.js', function (window, jquery) {
window.jQuery('a[id$=hypGame]').each(function () {
agent.addUrl('/stats/reach'+this.href);
});
});
// Go to the next page in the sequence
agent.next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment