page-link-checker
v1.3.0
Published
Check links in a page (via a URL) or supplied HTML
Downloads
14
Readme
Page Link Checker
Check links on a page are correct.
Install
npm install page-link-checker
Usage
var plc = require("page-link-checker")
// Check links on a page
var pageUrl = "https://github.com/adrianblynch?tab=repositories"
var baseUrl = "https://github.com/"
plc.check(pageUrl, baseUrl, function (err, responses) {
console.log("Page URL:", responses)
})
// Check links in HTML
var html = "<a href='https://github.com/adrianblynch'>My Github</a><a href='https://github.com/adrianblynch?tab=repositories'>My Github Repos</a>"
plc.check(html, function (err, responses) {
console.log("HTML:", responses)
})
// Get broken links
var html = [
"<a href='https://github.com/adrianblynch'>My Github</a>",
"<a href='https://github.com/adrianblynch?tab=repositories'>My Github Repos</a>",
"<a href='https://github.com/adrianblynch/dude-wheres-my-buses'>A 404 link</a>"
].join("")
plc.check(html, function (err, responses) {
responses = responses.filter(function (response) {
return response.request.statusCode !== 200
})
console.log("Broken links:", responses);
})