mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 22:26:19 +00:00
mostrar path a html debug junto al error
This commit is contained in:
parent
4f5994a2e1
commit
3c9788647b
1 changed files with 4 additions and 4 deletions
|
@ -49,7 +49,7 @@ export async function downloadList(path: string) {
|
||||||
type ScrapResult =
|
type ScrapResult =
|
||||||
| { type: "skipped" }
|
| { type: "skipped" }
|
||||||
| { type: "done" }
|
| { type: "done" }
|
||||||
| { type: "error"; url: string; error: any };
|
| { type: "error"; url: string; error: any; debugPath: string };
|
||||||
async function scrap(urlS: string): Promise<ScrapResult> {
|
async function scrap(urlS: string): Promise<ScrapResult> {
|
||||||
let url;
|
let url;
|
||||||
try {
|
try {
|
||||||
|
@ -87,17 +87,17 @@ async function scrap(urlS: string): Promise<ScrapResult> {
|
||||||
|
|
||||||
return { type: "done" };
|
return { type: "done" };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const urlHash = createHash("md5").update(urlS).digest("hex");
|
||||||
|
const output = join("debug", `${urlHash}.html`);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
const urlHash = createHash("md5").update(urlS).digest("hex");
|
|
||||||
const output = join("debug", `${urlHash}.html`);
|
|
||||||
await mkdir("debug", { recursive: true });
|
await mkdir("debug", { recursive: true });
|
||||||
await writeFile(output, html);
|
await writeFile(output, html);
|
||||||
console.error(`wrote html to ${output}`);
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: "error",
|
type: "error",
|
||||||
url: urlS,
|
url: urlS,
|
||||||
error,
|
error,
|
||||||
|
debugPath: output,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue