Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created August 11, 2010 18:51
Show Gist options
  • Save indexzero/519516 to your computer and use it in GitHub Desktop.
Save indexzero/519516 to your computer and use it in GitHub Desktop.
var httpAgent = require('http-agent'),
sys = require('sys');
var agent = httpAgent.create('www.google.com', ['finance', 'news', 'images']);
agent.addListener('next', function (agent) {
setTimeout(function () {
sys.puts('Body of the current page: ' + agent.body);
sys.puts('Response we saw for this page: ' + agent.response);
// Go to the next page in the sequence
agent.next();
}, 200);
});
agent.addListener('stop', function (agent) {
sys.puts('the agent has stopped');
});
agent.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment