Home > Web Front-end > JS Tutorial > body text

Check Links with Google Spreadsheet

WBOY
Release: 2024-07-22 07:11:28
Original
991 people have browsed it

In this tutorial I'll show you how you can check multiple links with a Google Check Links with Google Spreadsheet and a simple Google Apps Script.

You may find this article useful if you have a lot of links and want to find broken ones, or for example, if you are testing some API endpoints with different parameters, headers, or body and want to check http responses.

Check Links with Google Spreadsheet

Check Links with Google Spreadsheet + Google Apps Script:

https://docs.google.com/spreadsheets/d/1UyuKCRO8BWcIaluGEYTuUZglBryo0uFBji2a6tbBXCw/copy

Github Page:

https://github.com/Vryntel/Check Links with Google Spreadsheet-Url-Tester

Check Links with Google Spreadsheet Structure

The spreadsheet is composed by 2 sheet:

  • Data
  • Settings

The Data sheet use the following columns:

  • Column A: URL
  • Column B: HTTP request method (Supported HTTP request methods: GET, POST, DELETE, PATCH, PUT)
  • Column C: params in JSON format

Example:
URL: https://mywebsite.com
PARAMS: {"param1":"test", "params2":"test2"}
FETCHED URL: https://mywebsite.com?param1=test¶m2=test2

  • Column D: headers in JSON format
  • Column E: Body Type that can be JSON or TEXT
  • Column F: body in JSON/TEXT format
  • Column G: Response Code returned by the request
  • Column H: Response Body returned by the request

In the Settings sheet you can edit some adavnced settings of the HTTP requests:

  • validateHttpsCertificates: TRUE/FALSE --> If FALSE the fetch ignores any invalid certificates for HTTPS requests
  • followRedirects: TRUE/FALSE --> If FALSE the fetch doesn't automatically follow HTTP redirects; it returns the original HTTP response

Usage

After making a copy of the spreadsheet, in the top toolbar will appear the option "Url Tester" and then "Test Urls" (if it doesn't appear try to reload the page).

To run the script you need to click Test Urls option. Only the first time it will ask you to grant permission for the script to be executed.

If you only need to use the spreadsheet to check for broken links, you can use only the column A to insert the links and in the column B you can leave the GET method for each url row. When you run the script, the response code will appear in the column G and if it's OK it will be printed the code 200, otherwise another code, you can see all possible codes here:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

Some notes:

  • Google Apps Script has some limitations regarding URL Fetch calls ( at the moment is 20,000 / day). So if you have more than 20,000 URLs to test, consider to split them in more groups and test in multiple days. There are also other limitations regardings headers size, response size ecc. You can find all the limitations here:

https://developers.google.com/apps-script/guides/services/quotas

  • You can hide (not delete) some columns that you don't need, for example columns C, D, E, F.

The above is the detailed content of Check Links with Google Spreadsheet. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!