This commit is contained in:
root 2025-10-21 13:30:10 +07:00
parent 0e39c66902
commit 5237ceaba1
1 changed files with 4 additions and 2 deletions

View File

@ -7,7 +7,7 @@ import path from "path";
import dayjs from "dayjs"; import dayjs from "dayjs";
import mysql from "mysql2/promise"; import mysql from "mysql2/promise";
const EMAILS = ["andrew.ng@apactech.io"]; const EMAILS = ["andrew.ng@apactech.io", "dev@apactech.io"];
const LIST_STORE = [ const LIST_STORE = [
{ {
@ -128,8 +128,10 @@ async function scrapeWithCheerio(url) {
const priceText = $(el).find(".s-card__price").text().trim().replace(",", ""); const priceText = $(el).find(".s-card__price").text().trim().replace(",", "");
const match = priceText.match(/([£$€A-Za-z]{1,5})?\s?([\d.,]+)\s?([£$€A-Za-z]{1,5})?/); const match = priceText.match(/([£$€A-Za-z]{1,5})?\s?([\d.,]+)\s?([£$€A-Za-z]{1,5})?/);
if (match) { if (match) {
const currency = match[1] || match[3] || "";
payload.price = match[2]; payload.price = match[2];
payload.currency = match[1] || match[3]; payload.currency = currency.replace("£", "GBP").replace("$", "USD");
if(!payload.currency?.trim()) payload.currency = "USD";
} }
if (payload.id) items.push(payload); if (payload.id) items.push(payload);