Created
May 10, 2011 11:53
-
-
Save patrickkettner/964332 to your computer and use it in GitHub Desktop.
tinkering with node.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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