From 68838c9e0da8c74f9921e4d89e459275f9d235ce Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 28 Apr 2024 12:44:00 -0700 Subject: [PATCH] Update single_url.ts --- apps/api/src/scraper/WebScraper/single_url.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/api/src/scraper/WebScraper/single_url.ts b/apps/api/src/scraper/WebScraper/single_url.ts index 262a90c..ff73e95 100644 --- a/apps/api/src/scraper/WebScraper/single_url.ts +++ b/apps/api/src/scraper/WebScraper/single_url.ts @@ -20,10 +20,15 @@ export async function generateRequestParams( headers: { "ScrapingService-Request": "TRUE" }, }; - const urlKey = new URL(url).hostname; - if (urlSpecificParams.hasOwnProperty(urlKey)) { - return { ...defaultParams, ...urlSpecificParams[urlKey] }; - } else { + try { + const urlKey = new URL(url).hostname; + if (urlSpecificParams.hasOwnProperty(urlKey)) { + return { ...defaultParams, ...urlSpecificParams[urlKey] }; + } else { + return defaultParams; + } + } catch (error) { + console.error(`Error generating URL key: ${error}`); return defaultParams; } }