Update scrap_new_items.js
This commit is contained in:
parent
bfbd1c497f
commit
5f4db503e4
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue