Created
January 20, 2018 17:06
-
-
Save elliotforbes/fc35bd4e9e5a800610911c63a16ba0ef to your computer and use it in GitHub Desktop.
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 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