Use regex in server.all to match all routes Remove request interception
Some checks failed
GBCI / build (push) Failing after 3m0s
Some checks failed
GBCI / build (push) Failing after 3m0s
from KBService Drop request interception to simplify navigation. Add a page.evaluate to strip images, scripts, and stylesheets.
This commit is contained in:
parent
9d7f86c23f
commit
5a89721fd8
1 changed files with 6 additions and 13 deletions
|
@ -1691,19 +1691,6 @@ export class KBService implements IGBKBService {
|
|||
|
||||
const fileName = `${flatLastPath}.html`;
|
||||
const filePath = path.join(directoryPath, fileName);
|
||||
// Configure request interception before navigation
|
||||
await page.setRequestInterception(true);
|
||||
page.on('request', request => {
|
||||
if (request.resourceType() === 'document') {
|
||||
request.continue().catch(() => {
|
||||
// Ignore errors from requests that were already handled
|
||||
});
|
||||
} else {
|
||||
request.abort().catch(() => {
|
||||
// Ignore errors from requests that were already handled
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Navigate with strict timeout and wait for content
|
||||
// Navigate and get content even if page fails to load fully
|
||||
|
@ -1717,6 +1704,12 @@ export class KBService implements IGBKBService {
|
|||
// Ignore timeout/navigation errors
|
||||
}
|
||||
|
||||
await page.evaluate(() => {
|
||||
// Remove images, scripts, stylesheets, etc.
|
||||
const elements = document.querySelectorAll('img, script, link[rel="stylesheet"]');
|
||||
elements.forEach(el => el.remove());
|
||||
});
|
||||
|
||||
// Get whatever HTML content was loaded
|
||||
const htmlContent = await page.content();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue