Update scrap_new_items.js

This commit is contained in:
nguyentrungthat 2025-12-10 17:13:21 +07:00
parent 1d3de8a2ab
commit b60b517f8c
1 changed files with 4 additions and 4 deletions

View File

@ -147,7 +147,7 @@ async function scrapeWithPuppeteer(store) {
if (priceEl) {
let text = priceEl.textContent.replace(",", "").trim();
text = text.replace("£", "GBP ").replace("$", "");
payload.priceText = text;
const match = text.match(/([A-Za-z]{3})?\s?([\d.,]+)\s?([A-Za-z]{3})?/);
if (match) {
payload.currencyID = match[1] || match[3] || "";
@ -158,7 +158,7 @@ async function scrapeWithPuppeteer(store) {
payload.currencyID = match[1] || match[3] || "";
}
}
if (!payload.currencyID?.trim()) payload.currencyID = "AU";
// if (!payload.currencyID?.trim()) payload.currencyID = "";
}
}
@ -401,7 +401,7 @@ async function main() {
// 3⃣ Insert new record
const title = (item.title || "").replace("Opens in a new window or tab", "").trim();
// console.log({ ...item, title });
console.log({ ...item, title });
await axios
.post(
process.env.API_DISTI_HOST + "/api/items/insert",