function updateViews() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getRange("B1:C" + sheet.getLastRow()).getValues();
for (var i = 0; i < data.length; i++) {
var url = data[i][0];
if (url !== "") {
var response = UrlFetchApp.fetch(url);
var content = response.getContentText();
var match = content.match(/<span class="views__value">([\d\s, ]+)<\/span>/);
if (match) {
var viewsValue = match[1].replace(/\s| |,/g, "");
sheet.getRange(i + 1, 3).setValue(viewsValue); // Update corresponding cell in column C
}
}
}
}
function setupTrigger() {
ScriptApp.newTrigger('updateViews')
.timeBased()
.everyHours(1)
.create();
}