Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function testUrl(){
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName("PIMS");
var data = sheet.getRange(2,5,sheet.getLastRow(),1).getValues();
for (var i = 0; i < data.length; i++){
var responseCode = "-";
if (data[i][0].substring(0,4)=="http"){
try
{
var response = UrlFetchApp.fetch(data[i][0]);
responseCode = response.getResponseCode();
}
catch (e)
{
responseCode = e.message;
Logger.log(responseCode);
if (responseCode.indexOf("404.")>0){
responseCode = "404";
}else if (responseCode.indexOf("403.")>0){
responseCode = "403";
}else if (responseCode.indexOf("503.")>0){
responseCode = "503";
}else if (responseCode.indexOf("500.")>0){
responseCode = "500";
}
else if (responseCode.indexOf("590.")>0){
responseCode = "590";
}
}
sheet.getRange(i+2,6).setValue(responseCode);
}
}
}
@meoso

This comment has been minimized.

Copy link

meoso commented Feb 25, 2016

very interesting, is there a possibility of ping IP response?

i.e. ICMP, not HTTP

@mangoblogger

This comment has been minimized.

Copy link

mangoblogger commented Jul 22, 2018

That's awesome!
One can also use this add-on to find HTTP status code in a Google sheet - https://chrome.google.com/webstore/detail/seomango/oigecakbpjpkahfaeblingmgdhnjiknc?hl=en

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.