Update scrap_new_items.js
This commit is contained in:
parent
1d3de8a2ab
commit
b60b517f8c
|
|
@ -146,8 +146,8 @@ async function scrapeWithPuppeteer(store) {
|
|||
const priceEl = node.querySelector(".s-card__price");
|
||||
if (priceEl) {
|
||||
let text = priceEl.textContent.replace(",", "").trim();
|
||||
text = text.replace("£", "GBP").replace("$", "");
|
||||
|
||||
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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue