From d9ff36297ac95966ed25e04bc42da46481f23f8a Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 26 May 2025 09:37:23 +0700 Subject: [PATCH] update gray scraping --- scrape-data-keyword/models/grays-scrap-model.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scrape-data-keyword/models/grays-scrap-model.js b/scrape-data-keyword/models/grays-scrap-model.js index 328f85d..15e9df0 100644 --- a/scrape-data-keyword/models/grays-scrap-model.js +++ b/scrape-data-keyword/models/grays-scrap-model.js @@ -20,8 +20,8 @@ export class GraysScrapModel extends ScrapModel { getPriceByEl = async (elementHandle) => { const selectors = [ - ".sc-ijDOKB.sc-bStcSt.ikmQUw.eEycyP", // Single product price - ".sc-ijDOKB.ikmQUw", // Multiple product price + "a > div:nth-child(2) > div:nth-child(2)", // Single product price + "a > div:nth-of-type(2) > div:nth-of-type(2) > div > div:nth-of-type(1) > div", // Multiple product price ]; for (const selector of selectors) { @@ -43,17 +43,15 @@ export class GraysScrapModel extends ScrapModel { for (const el of elements) { const url = await el - .$eval(".sc-pKqro.sc-gFnajm.gqkMpZ.dzWUkJ", (el) => - el.getAttribute("href") - ) + .$eval("a", (el) => el.getAttribute("href")) .catch(() => null); const image_url = await el - .$eval("img.sc-gtJxfw.jbgdlx", (img) => img.getAttribute("src")) + .$eval("img", (img) => img.getAttribute("src")) .catch(() => null); const name = await el - .$eval(".sc-jlGgGc.dJRywx", (el) => el.textContent.trim()) + .$eval("h2", (el) => el.textContent.trim()) .catch(() => null); const current_price = await this.getPriceByEl(el); // Gọi hàm async được định nghĩa trong class -- 2.39.2