Skip to content

Instantly share code, notes, and snippets.

@dmjcomdem
Last active September 16, 2017 00:15
Show Gist options
  • Save dmjcomdem/d4173b5c5e967266ea80e5426438dde8 to your computer and use it in GitHub Desktop.
Save dmjcomdem/d4173b5c5e967266ea80e5426438dde8 to your computer and use it in GitHub Desktop.
parseGoogleSheet
function getContent() {
var listItem = 12;
var paginationPage = 95;
var iterationCount = Math.ceil(paginationPage/listItem);
for(var i = 1; i <= iterationCount; i++) {
getPageContent(i + (i-1)*12, url);
}
}
function getPageContent(startRow, url) {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange('A1:B181');
var cell = range.getCell(startRow,1);
var response = UrlFetchApp.fetch(url);
var textResp = response.getContentText();
var listItem = 12;
var start, end, name, link, i;
for(i = 1; i <= listItem; i++) {
start = textResp.indexOf('<h3 class="miniCard__headerTitle"><a href="', end) + 43 ;
end = textResp.indexOf('" class="miniCard__headerTitleLink">', start);
link = textResp.slice(start, end)
start = textResp.indexOf('class="miniCard__headerTitleLink">', end) + 34 ;
end = textResp.indexOf('</a>', start);
name = textResp.slice(start, end)
if(start != -1 && end != -1) {
cell.setValue( '=HYPERLINK("' + link + '";" '+ name + '")' );
cell = cell.offset(1,0);
} else {
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment