Skip to content

Instantly share code, notes, and snippets.

@elliotforbes
Created January 20, 2018 17:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotforbes/fc35bd4e9e5a800610911c63a16ba0ef to your computer and use it in GitHub Desktop.
Save elliotforbes/fc35bd4e9e5a800610911c63a16ba0ef to your computer and use it in GitHub Desktop.
var request = require('request');
var blc = require('broken-link-checker');
exports.handler = function(event, context, callback) {
let response = {
status: 'success',
links: [],
brokenLinks: []
};
let htmlUrlChecker = new blc.HtmlUrlChecker(null, {
junk: function(result) {
response.brokenLinks.push(result.url.resolved);
},
link: function(result) {
response.links.push(result.url.resolved);
},
end: function() {
console.log(response);
callback(null,response);
}
});
htmlUrlChecker.enqueue(event.url, null);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment