getTitle
function getTitle(tURL) {
var objSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var objSheet = objSpreadsheet.getActiveSheet();
var objCell = objSheet.getActiveCell();
var response = UrlFetchApp.fetch(tURL);
var myRegexp = /<title>([\s\S]*?)<\/title>/i;
var match = myRegexp.exec(response.getContentText());
var title = match[1];
title = title.replace(/(^\s+)|(\s+$)/g, "");
//objCell.setValue(title)
if(title==null){
return "NULL";
}else{
return title;
}
}
getDescription
function getDescription(tURL) {
var objSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var objSheet = objSpreadsheet.getActiveSheet();
var objCell = objSheet.getActiveCell();
var response = UrlFetchApp.fetch(tURL);
var myRegexp = /<meta name=\"description\" .*content=\"([\s\S]*?)(\".*\/|\".*)>/i;
var match = myRegexp.exec(response.getContentText());
var title = match[1];
title = title.replace(/(^\s+)|(\s+$)/g, "");
// objCell.setValue(title)
if(title==null){
return "NULL";
}else{
return title;
}
}