Update scrap_new_items.js

This commit is contained in:
nguyentrungthat 2025-12-10 16:06:28 +07:00
parent bfbd1c497f
commit 5f4db503e4
1 changed files with 6 additions and 5 deletions

View File

@ -145,13 +145,14 @@ async function scrapeWithPuppeteer(store) {
// ---------------- PRICE + CURRENCY ----------------
const priceEl = node.querySelector(".s-card__price");
if (priceEl) {
let text = priceEl.textContent.replace(/,/g, "").trim();
let text = priceEl.textContent.replace(",", "").trim();
text = text.replace("£", "GBP").replace("$", "");
const m = text.match(/([A-Za-z]{2,4})?\s?([\d.]+)\s?([A-Za-z]{2,4})?/);
if (m) {
payload.currencyID = m[1] || m[3] || "AU";
payload.price = m[2] || "";
const match = text.match(/([A-Za-z]{3})?\s?([\d.,]+)\s?([A-Za-z]{3})?/);
if (match) {
payload.currencyID = match[1] || match[3] || "";
payload.price = match[2] || "";
if (!payload.currency?.trim()) payload.currency = "AU";
}
}