Google Sheet is one of the amazing and free online spreadsheet program that can be used for almost anything about calculations. In this blog post, I am going to share how to pull an HTTP Response code in Google Sheet. This might be helpful if you wanted to see HTTP Status code of multiple website in one go without opening each website manually in your browser. Cool, isn’t it? It is also a time saver.
If you are a blogger or webmaster monitoring a list of domains, sites or URL then you might need to check HTTP Status many times. To overcome this issue, I have made it simple. You will get 200 and 301 for working websites, or will get any other response code like 500 or 404.
We have to use the following formula to get HTTP Response Code.
=HTTPResponse(CELL CONTAINING LINK)
To make the above formula work we have to insert a code in Google Sheet that will make the formula run. To insert the formula, first open Script Editor.
Tools » Script Editor » Name Your Script Editor » OK » Add Below Code.
/*
Check Websites for HTTP Response
Source: https://www.atulhost.com/how-to-pull-an-http-response-code-in-google-sheet
*/
function HTTPResponse( uri )
{
var response_code ;
try {
response_code = UrlFetchApp .fetch( uri ) .getResponseCode() .toString() ;
}
catch( error ) {
response_code = error .toString() .match( / returned code (\d\d\d)\./ )[1] ;
}
finally {
return response_code ;
}
}
…and don’t forget to Save it… :)
Now you are ready to check as many as possible HTTP Header Status Code in just few moments and can save time on manual website checks.
Leave a Reply