How do I Check Broken Links Using Google Sheets

How do I Check Broken Links Using Google Sheets.

Checking for damaged hyperlinks could be a tedious process, particularly when you’ve a protracted listing of URLs. Manually placing every URL right into a browser to examine isn’t sensible. In this put up, I’m going to point out you the way to do it without cost and virtually routinely, using Google Sheets.

Check broken links with Google SheetsCheck broken links with Google Sheets

By the tip of this tutorial, you’ll have a Google Sheet that allows you to listing as many URLs as you need in a single column. The column next to it should present you the HTTP standing of every URL. This will make it easier to perceive if the web page is accessible, redirected, damaged, and so forth.

Step 1: Create a New Google Sheet

Create a brand new Google Sheet and import your listing of hyperlinks, or you possibly can manually add them. Organize them in a column labeled “URL” and one other labeled “Status,” like this:

Example of Google Sheet with URL and Status ColumnsExample of Google Sheet with URL and Status Columns

Step 2: Open Google Apps Script

In the Google Sheet’s toolbar on the prime, go to Extensions > App Scripts.

This will open the Google Apps Script editor, the place you possibly can create your individual customized capabilities. We’re going to create a operate that takes a URL as enter and returns its HTTP standing. Don’t fear, no coding expertise are wanted for this part.

Googel Apps ScriptGoogel Apps Script

Step 3: Paste the Code

Copy the code supplied beneath, paste it into the editor, and provides your undertaking a reputation, like “Get HTTP Status.

operate getHTTPStatus( uri )
{
  var response_code ;
  attempt {
    response_code = UrlFetchApp .fetch( uri ) .getResponseCode() .toString() ;
  }
  catch( error ) {
    response_code = error .toString() .match( / returned code (ddd)./ )[1] ;
  }
  lastly {
    return response_code ;
  }
}

Step 4: Save and Close

Click on the small Disk icon to save lots of your undertaking. You can then shut the Apps Script browser window.

Disk icon

If you’re interested by what the operate does and need to perceive it higher, see beneath for a proof.

What the Function Does:

This script, named getHTTPStatus, is designed to retrieve response codes from net addresses (URLs). It’s a simple software for understanding the standing of a URL and the kind of response it supplies.

Here’s a breakdown of its capabilities:

  1. Setting Up: Initializes the method to seize the response code from the URL.

  2. Try it and Catch Errors: Employs a technique to deal with potential errors throughout URL checks.

    • Try it: Attempts to hook up with the URL. If profitable, retrieves and shops the standing code.

    • Catch: If a connection error happens, this part extracts the response code from the error message and shops it.

  3. Finish Up: Ultimately, returns the response code it obtained, whatever the earlier outcomes.

In essence, the getHTTPStatus operate is a software to examine a URL’s standing and establish potential points primarily based on the response code.

Step 5: Testing the Function

With the operate now prepared, it’s time to check it. Navigate to the cell next to the primary URL and enter the next method:

=getHTTPStatus(A2)
Testing Function with FormulaTesting Function with Formula

If the URL is reachable, it’s best to see a return worth of 200. This signifies profitable entry.

To apply this to different URLs, you possibly can lengthen the method to further cells. This may be accomplished by dragging the nook of the cell downwards, as proven right here:

Extending Formula to Other CellsExtending Formula to Other Cells

Alternatively, a fast methodology is to double-click on the bottom-right nook of the cell. This motion will routinely fill the remaining cells with the method.

Quick Fill Method for CellsQuick Fill Method for Cells

Ending Thoughts

And there you’ve it: a easy Google Sheets setup to examine the HTTP standing of a number of URLs with out guide effort.

To conclude, right here’s a short overview of widespread HTTP standing codes and their meanings. For more particulars on HTTP codes, discover our posts on The ABCs of HTTP Status Codes.

  • 200: Request profitable.
  • 301: The web page has completely moved to a brand new URL.
  • 400: Invalid request attributable to incorrect syntax.
  • 401: Login required to entry the web page.
  • 403: Access to the web page is denied.
  • 404: The web page doesn’t exist.
  • 500: General error on the server.
  • 503: Server quickly unavailable, typically attributable to overload or upkeep.


Check out more article on – How-To tutorial and latest highlights on – Technical News
Exit mobile version