function updateViews() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getRange("A2:B" + 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">([^<]+)<\/span>/); // Updated regex pattern
if (match) {
var viewsValue = match[1].replace(/[\s,]/g, ""); // Remove spaces and commas
sheet.getRange(i + 2, 2).setValue(viewsValue); // Update corresponding cell in column B
}
}
}
}
function setupTrigger() {
ScriptApp.newTrigger('updateViews')
.timeBased()
.everyHours(1)
.create();
}