From 7e58397c8ce64f2f8d67924b3b54bdd245b137fa Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 4 Jan 2024 15:30:25 -0300 Subject: [PATCH] siempre guardar html debug --- scraper/scrap.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scraper/scrap.ts b/scraper/scrap.ts index 07a473f..7d80820 100644 --- a/scraper/scrap.ts +++ b/scraper/scrap.ts @@ -1,5 +1,5 @@ import * as schema from "db-datos/schema.js"; -import { writeFile } from "fs/promises"; +import { writeFile, mkdir } from "fs/promises"; import { createHash } from "crypto"; import { getCarrefourProduct } from "./parsers/carrefour.js"; import { getDiaProduct } from "./parsers/dia.js"; @@ -8,7 +8,7 @@ import { join } from "path"; import { db } from "db-datos/db.js"; import pMap from "p-map"; -const DEBUG = false; +const DEBUG = true; const PARSER_VERSION = 4; export type Precio = typeof schema.precios.$inferInsert; @@ -78,6 +78,7 @@ export async function downloadList(path: string) { if (DEBUG) { const urlHash = createHash("md5").update(urlS).digest("hex"); const output = join("debug", `${urlHash}.html`); + await mkdir("debug", { recursive: true }); await writeFile(output, html); console.error(`wrote html to ${output}`); }