Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mhawksey
Created August 8, 2011 14:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhawksey/1131870 to your computer and use it in GitHub Desktop.
Save mhawksey/1131870 to your computer and use it in GitHub Desktop.
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
Copy link

meoso commented Feb 25, 2016

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

i.e. ICMP, not HTTP

@prasannakulkarni333
Copy link

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