Skip to content

Instantly share code, notes, and snippets.

@JoeyBurzynski
Last active September 11, 2024 18:13
Show Gist options
  • Save JoeyBurzynski/d8e336f80361e3ed258bb860e32c48d3 to your computer and use it in GitHub Desktop.
Save JoeyBurzynski/d8e336f80361e3ed258bb860e32c48d3 to your computer and use it in GitHub Desktop.
Google Sheets Function (SEO, How to Fetch HTTP Status Code for URL in Google Sheets)
/**
Google Sheets Function (Fetch HTTP Status Code for URL)
How to Fetch HTTP Status Code for URL in Google Sheets
Reference URL: https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
**/
function getStatusCode(url){
var options = {
'muteHttpExceptions': true,
'followRedirects': false
};
var url_trimmed = url.trim();
var response = UrlFetchApp.fetch(url_trimmed, options);
return response.getResponseCode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment