Pages

joi, 19 iunie 2025

News : Google Apps Script - get products by region into new sheet.

... this is source code for search products on my region using google apps script:
function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Ocazii Scraper')
    .addItem('Scrape placa-de-baza', 'scrapeProcess_placa_de_baza')
    .addToUi();
}

function scrapeProcess_placa_de_baza() {
  const url_placa_de_baza = "https://www.okazii.ro/componente-computere/placa-de-baza/?judete_lp=35&sort=pret_asc";
  let html;
  try {
    const response = UrlFetchApp.fetch(url_placa_de_baza);
    html = response.getContentText();
  } catch (error) {
    Logger.log("Error fetching HTML: " + error.message);
    return;
  }

  const itemRegex = /<div class="list-item[\s\S]*?<h2>[\s\S]*?<a[^>]+href="(.*?)"[^>]+title="(.*?)"[\s\S]*?<span class="prSup"><span>(\d+)<\/span>[\s\S]*?<span class="prList"><span>([\d,]+)<\/span>/g;

  const spreadsheetName = "placa_baza_200625";
  const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = spreadsheet.getSheetByName(spreadsheetName) || spreadsheet.insertSheet(spreadsheetName);

  // Adaugă headere dacă e un sheet nou
  if (sheet.getLastRow() === 0) {
    sheet.appendRow(["Data", "Titlu", "Href", "Pret", "Livrare"]);
  }

  const now = new Date();
  const formattedDate = Utilities.formatDate(now, SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "ddMMyy");

  let match;
  while ((match = itemRegex.exec(html)) !== null) {
    let [_, href, title, price, delivery] = match;
    delivery = delivery.replace(",", "."); // înlocuiește virgula pentru formatare numerica
    const row = [formattedDate, title, href, price, delivery];
    sheet.appendRow(row);
  }
}

News : Construct 3 r444.2 Beta.

A new Beta version of Construct 3 has just been published - please note that Beta versions are not as thoroughly tested as Stable versions. If you choose to use Beta versions, please ensure you backup your work regularly and are willing to file bug reports if you run into any issues.

News : Farmatic Official Reveal Trailer