I wonder how can I execute the code faster or bypass the runtime limit. Here is a sample. Among the other elements are rating and number of ratings, Coupon, Product Description. I've repeatedly used the loop over each element so I guess that's what slowed the script way down.
function priceScraper(){
var apiKey= SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Settings").getRange(1,2).getValue();
var scraperSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Scraper")
var lrow=scraperSheet.getLastRow();
for(var i= 2; i<=lrow; i++){
var url = "http://api.scraperapi.com?api_key=" + apiKey + "&url=https://www.amazon.com/dp/"+scraperSheet.getRange(i, 1).getValue()
var regEx = /<span aria-hidden="true".*<\/span>/gi
//<span aria-hidden="true">$11.80</span>
var getContent = UrlFetchApp.fetch(url).getContentText().trim();
var price= getContent.match(regEx);
price=price[0];
price = price.replace('<span aria-hidden="true"><span class="a-price-symbol">', "").replace('<span aria-hidden="true">', "").replace('</span><span class="a-price-whole">', "").replace('<span class="a-price-decimal">', "").replace('</span></span><span class="a-price-fraction">',"").replace('</span></span></span>',"").replace("</span></span>", "")
scraperSheet.getRange(i,2).setValue(price)
}
I know that the code can be shortened but I don't know how.