mirror of
https://github.com/intergalacticalvariable/reader.git
synced 2024-11-16 03:32:25 +08:00
fix: catch parse error
This commit is contained in:
parent
3134a59d8f
commit
18373626b2
|
@ -118,12 +118,21 @@ export class PuppeteerControl extends AsyncService {
|
|||
preparations.push(page.evaluateOnNewDocument(READABILITY_JS));
|
||||
preparations.push(page.evaluateOnNewDocument(`
|
||||
function giveSnapshot() {
|
||||
let parsedContent;
|
||||
try {
|
||||
// Attempt to parse the cloned document
|
||||
parsedContent = new Readability(document.cloneNode(true)).parse();
|
||||
} catch (error) {
|
||||
// If an error occurs, log it and set parsedContent to undefined
|
||||
parsedContent = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
title: document.title,
|
||||
href: document.location.href,
|
||||
html: document.documentElement.outerHTML,
|
||||
text: document.body.innerText,
|
||||
parsed: new Readability(document.cloneNode(true)).parse(),
|
||||
parsed: parsedContent
|
||||
};
|
||||
}
|
||||
`));
|
||||
|
|
Loading…
Reference in New Issue
Block a user