Change the way the playwright response is parsed
Was failing with a Type Error, but actually looked ok. This fixes the type error, and stop scraper fallback.
This commit is contained in:
parent
14896a9fdd
commit
deefe65cbe
@ -146,12 +146,18 @@ export async function scrapWithPlaywright(url: string, waitFor: number = 0): Pro
|
|||||||
if (contentType && contentType.includes('application/pdf')) {
|
if (contentType && contentType.includes('application/pdf')) {
|
||||||
return fetchAndProcessPdf(url);
|
return fetchAndProcessPdf(url);
|
||||||
} else {
|
} else {
|
||||||
const data = await response.json();
|
const textData = await response.text();
|
||||||
const html = data.content;
|
try {
|
||||||
return html ?? "";
|
const data = JSON.parse(textData);
|
||||||
|
const html = data.content;
|
||||||
|
return html ?? "";
|
||||||
|
} catch (jsonError) {
|
||||||
|
console.error(`[Playwright] Error parsing JSON response for url: ${url} -> ${jsonError}`);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[Playwright][c] Error fetching url: ${url} -> ${error}`);
|
console.error(`[Playwright] Error fetching url: ${url} -> ${error}`);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user