From f85c74a7bcdd9e3b9be9c4454a0bac676f831321 Mon Sep 17 00:00:00 2001 From: Nulo Date: Mon, 1 Jan 2024 16:49:52 -0300 Subject: [PATCH] borrar parsers no usados --- scraper/parsers/carrefour.ts | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/scraper/parsers/carrefour.ts b/scraper/parsers/carrefour.ts index 4f6aa83..e3f74fa 100644 --- a/scraper/parsers/carrefour.ts +++ b/scraper/parsers/carrefour.ts @@ -1,20 +1,7 @@ import { parseHTML } from "linkedom"; -import { Precioish, type Precio } from "../scrap.js"; +import { Precioish } from "../scrap.js"; import { getProductJsonLd, priceFromMeta, stockFromMeta } from "../common.js"; -function getEanByTable(dom: Window): string { - const eanLabelEl = dom.window.document.querySelector( - 'td[data-specification="EAN"]' - ); - const eanValueEl = eanLabelEl?.parentElement?.children[1]; - if ( - !eanValueEl || - !(eanValueEl instanceof dom.window.HTMLElement) || - !eanValueEl.dataset.specification - ) - throw new Error("No encontré el EAN"); - return eanValueEl.dataset.specification; -} function parseScriptJson(dom: Window, varname: string): T { const script = dom.window.document.querySelector( `template[data-type="json"][data-varname="${varname}"]` @@ -37,18 +24,6 @@ function eanFromSeedState(dom: Window): string { if (!productSkuJson) throw new Error("no encontré el sku en el json"); return productSkuJson[1].ean; } -function eanFromDynamicYieldScript(dom: Window): string { - const scriptEl = dom.window.document.querySelector( - `script[src^="//st.dynamicyield.com/st?"]` - ); - if (!scriptEl || !(scriptEl instanceof dom.window.HTMLScriptElement)) - throw new Error("no encuentro el script de dynamicyield"); - - const url = new URL(scriptEl.src); - const ctx = url.searchParams.get("ctx"); - if (!ctx) throw new Error("no hay ctx"); - return JSON.parse(ctx).data[0]; -} export function getCarrefourProduct(html: string | Buffer): Precioish { const dom = parseHTML(html);