Update
This commit is contained in:
parent
0e39c66902
commit
5237ceaba1
6
index.js
6
index.js
|
|
@ -7,7 +7,7 @@ import path from "path";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import mysql from "mysql2/promise";
|
import mysql from "mysql2/promise";
|
||||||
|
|
||||||
const EMAILS = ["andrew.ng@apactech.io"];
|
const EMAILS = ["andrew.ng@apactech.io", "dev@apactech.io"];
|
||||||
|
|
||||||
const LIST_STORE = [
|
const LIST_STORE = [
|
||||||
{
|
{
|
||||||
|
|
@ -128,8 +128,10 @@ async function scrapeWithCheerio(url) {
|
||||||
const priceText = $(el).find(".s-card__price").text().trim().replace(",", "");
|
const priceText = $(el).find(".s-card__price").text().trim().replace(",", "");
|
||||||
const match = priceText.match(/([£$€A-Za-z]{1,5})?\s?([\d.,]+)\s?([£$€A-Za-z]{1,5})?/);
|
const match = priceText.match(/([£$€A-Za-z]{1,5})?\s?([\d.,]+)\s?([£$€A-Za-z]{1,5})?/);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
const currency = match[1] || match[3] || "";
|
||||||
payload.price = match[2];
|
payload.price = match[2];
|
||||||
payload.currency = match[1] || match[3];
|
payload.currency = currency.replace("£", "GBP").replace("$", "USD");
|
||||||
|
if(!payload.currency?.trim()) payload.currency = "USD";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.id) items.push(payload);
|
if (payload.id) items.push(payload);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue