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");
|
const priceEl = node.querySelector(".s-card__price");
|
||||||
if (priceEl) {
|
if (priceEl) {
|
||||||
let text = priceEl.textContent.replace(",", "").trim();
|
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})?/);
|
const match = text.match(/([A-Za-z]{3})?\s?([\d.,]+)\s?([A-Za-z]{3})?/);
|
||||||
if (match) {
|
if (match) {
|
||||||
payload.currencyID = match[1] || match[3] || "";
|
payload.currencyID = match[1] || match[3] || "";
|
||||||
|
|
@ -158,7 +158,7 @@ async function scrapeWithPuppeteer(store) {
|
||||||
payload.currencyID = match[1] || match[3] || "";
|
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
|
// 3️⃣ Insert new record
|
||||||
const title = (item.title || "").replace("Opens in a new window or tab", "").trim();
|
const title = (item.title || "").replace("Opens in a new window or tab", "").trim();
|
||||||
// console.log({ ...item, title });
|
console.log({ ...item, title });
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
process.env.API_DISTI_HOST + "/api/items/insert",
|
process.env.API_DISTI_HOST + "/api/items/insert",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue