diff --git a/scraper/scrap.ts b/scraper/scrap.ts index 55d94d2..4d9ae9b 100644 --- a/scraper/scrap.ts +++ b/scraper/scrap.ts @@ -49,7 +49,7 @@ export async function downloadList(path: string) { type ScrapResult = | { type: "skipped" } | { type: "done" } - | { type: "error"; url: string; error: any }; + | { type: "error"; url: string; error: any; debugPath: string }; async function scrap(urlS: string): Promise { let url; try { @@ -87,17 +87,17 @@ async function scrap(urlS: string): Promise { return { type: "done" }; } catch (error) { + const urlHash = createHash("md5").update(urlS).digest("hex"); + const output = join("debug", `${urlHash}.html`); 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}`); } return { type: "error", url: urlS, error, + debugPath: output, }; } }