update gray scraping
This commit is contained in:
parent
7b2f5ecdec
commit
d9ff36297a
|
|
@ -20,8 +20,8 @@ export class GraysScrapModel extends ScrapModel {
|
||||||
|
|
||||||
getPriceByEl = async (elementHandle) => {
|
getPriceByEl = async (elementHandle) => {
|
||||||
const selectors = [
|
const selectors = [
|
||||||
".sc-ijDOKB.sc-bStcSt.ikmQUw.eEycyP", // Single product price
|
"a > div:nth-child(2) > div:nth-child(2)", // Single product price
|
||||||
".sc-ijDOKB.ikmQUw", // Multiple 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) {
|
for (const selector of selectors) {
|
||||||
|
|
@ -43,17 +43,15 @@ export class GraysScrapModel extends ScrapModel {
|
||||||
|
|
||||||
for (const el of elements) {
|
for (const el of elements) {
|
||||||
const url = await el
|
const url = await el
|
||||||
.$eval(".sc-pKqro.sc-gFnajm.gqkMpZ.dzWUkJ", (el) =>
|
.$eval("a", (el) => el.getAttribute("href"))
|
||||||
el.getAttribute("href")
|
|
||||||
)
|
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
|
|
||||||
const image_url = await el
|
const image_url = await el
|
||||||
.$eval("img.sc-gtJxfw.jbgdlx", (img) => img.getAttribute("src"))
|
.$eval("img", (img) => img.getAttribute("src"))
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
|
|
||||||
const name = await el
|
const name = await el
|
||||||
.$eval(".sc-jlGgGc.dJRywx", (el) => el.textContent.trim())
|
.$eval("h2", (el) => el.textContent.trim())
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
|
|
||||||
const current_price = await this.getPriceByEl(el); // Gọi hàm async được định nghĩa trong class
|
const current_price = await this.getPriceByEl(el); // Gọi hàm async được định nghĩa trong class
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue