Last active
July 2, 2020 15:56
-
-
Save seoutopico/28e7fe8732ee2a89fcf2d1eab5099107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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