Skip to content

Instantly share code, notes, and snippets.

@seoutopico
Last active July 2, 2020 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seoutopico/28e7fe8732ee2a89fcf2d1eab5099107 to your computer and use it in GitHub Desktop.
Save seoutopico/28e7fe8732ee2a89fcf2d1eab5099107 to your computer and use it in GitHub Desktop.
/*Obtenemos el status code*/
function getStatusCode(url){
var options = {
'muteHttpExceptions': true,
'followRedirects': false
};
var url_trimmed = url.trim();
var response = UrlFetchApp.fetch(url_trimmed, options);
return response.getResponseCode();
}
/*Obtenemos los elementos que nos intera de la web*/
function getContents(url) {
var result = UrlFetchApp.fetch(url);
var contents = result.getContentText();
return contents;
}
function Title(url) {
var html = getContents(url);
var title = html.match('<title>([^\<]+)</title>')[1];
return title;
}
function H1(url) {
var html = getContents(url);
var H1 = html.match('<h1>([^\<]+)</h1>')[1];
return H1;
}
function Robots(url) {
var html = getContents(url);
var Robots = html.match('<meta name=\"robots\" content=\"([^\<]+)\">')[1];
return Robots;
}
function Canonical(url){
var html = getContents(url);
var Canonical = html.match('<link .*nonical.* href="([^\<]+)"')[1];
return Canonical;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment