Node.js Express Broken Link Checker SEO Online Tool Deployed to Website + Source Code

Node.js Express Broken Link Checker SEO Online Tool Deployed to Website + Source Code

 

 

Welcome folks today in this tutorial we will be building broken link checker seo tool in node.js and express. All the source code of the app is shown below

 

 

Live Demo

 

 

You can check out the live demo of the tool right here 

 

 

Get Started

 

 

In order to get started you need to install these dependencies

 

npm i express ejs nodemon

 

And also one more dependency you need to install which is brkn-cli globally on your machine like this

 

npm i -g brkn-cli

 

And after this make the index.js file inside your node project

 

const {exec} = require('child_process')
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const prependhttp = require('prepend-http')
app.set('view engine', 'ejs')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))
app.get('/brokenlinkchecker', (req, res) => {
  res.render('brokenlinkchecker', {title: 'FREE Broken Links Checker Tool Online For Website and Domain - Broken Link Checker - FreeMediaTools.com',info: ''})
})

app.post('/brokenlinkchecker', (req, res) => {
  var url = prependhttp(req.body.url)

  exec(`brkn ${url} --verbose`, (err, stdout, stderr) => {

    if (err) {
      res.send(err)
    }

    console.log(stdout)

    res.render('brokenlinkchecker', {title: 'FREE Broken Links Checker Tool Online For Website and Domain - Broken Link Checker - FreeMediaTools.com',info: stdout})
  })
})

app.listen(5000)

 

READ  How to Encrypt PDF Files with Password in Node.js Using Hummus Recipe Library

 

Now you need to create a views folder inside the root directory to store the ejs templates and inside it you need to make brokenlinkchecker.ejs file

 

 

<!DOCTYPE html>
<html>
  <head>
    <title><%=title%></title>
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    />
  </head>
<div class="container">
    <h1 class="text-center">
      Broken Link Checker Online
    </h1>
    <form action="/brokenlinkchecker" method="post">
      <div class="form-group">
        <label for="url">Website URL:</label>
        <input class="form-control" type="text" name="url" id="" placeholder="URL of Website" required>
      </div>
      <div class="form-group">
        <button class="btn btn-block btn-danger">
          Get Broken Links
        </button>
      </div>
      <div class="form-group">
      <label for="links">Broken Links:</label>
      <textarea class="form-control" id="" cols="30" rows="10" placeholder="Broken Links"><%=info%></textarea>
    </div>
    </form>

    <body>
    </body>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    </html>

 

 

 

Screenshot

 

 

 

 

 

Leave a Reply