Spaces:
Running
Running
feat(websearch): skip pages that dont return success (#1639)
Browse files
src/lib/server/websearch/scrape/scrape.ts
CHANGED
@@ -35,6 +35,7 @@ export const scrape = (maxCharsPerElem: number) =>
|
|
35 |
export async function scrapeUrl(url: string, maxCharsPerElem: number) {
|
36 |
return withPage(url, async (page, res) => {
|
37 |
if (!res) throw Error("Failed to load page");
|
|
|
38 |
|
39 |
// Check if it's a non-html content type that we can handle directly
|
40 |
// TODO: direct mappings to markdown can be added for markdown, csv and others
|
|
|
35 |
export async function scrapeUrl(url: string, maxCharsPerElem: number) {
|
36 |
return withPage(url, async (page, res) => {
|
37 |
if (!res) throw Error("Failed to load page");
|
38 |
+
if (!res.ok()) throw Error(`Failed to load page: ${res.status()}`);
|
39 |
|
40 |
// Check if it's a non-html content type that we can handle directly
|
41 |
// TODO: direct mappings to markdown can be added for markdown, csv and others
|