Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created May 10, 2011 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickkettner/964332 to your computer and use it in GitHub Desktop.
Save patrickkettner/964332 to your computer and use it in GitHub Desktop.
tinkering with node.io
var nodeio = require('node.io');
exports.job = new nodeio.Job({
input: process.argv.splice(3),
run: function(domain) {
var self = this;
try { //make sure it is a url
self.assert(domain).isUrl();
this.getHtml(domain, function(err, $) {
if (err) {
if (err === "redirects") {
domain = this.last.url;
self.retry(domain);
}
else {
self.retry();
}
}
else {
//Process the link
}
});
}
catch(err) { //input isnt a valid url
console.log('"'+domain+'" isnt a full url, silly');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment