Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
Change the way the playwright response is parsed
Matt Joycedeefe65cbe11
diff --git a/apps/api/src/scraper/WebScraper/single_url.ts b/apps/api/src/scraper/WebScraper/single_url.tsindex c7f9469ce..70b4aa67b 100644--- a/apps/api/src/scraper/WebScraper/single_url.ts+++ b/apps/api/src/scraper/WebScraper/single_url.ts@@ -146,12 +146,18 @@ export async function scrapWithPlaywright(url: string, waitFor: number = 0): Proif (contentType && contentType.includes('application/pdf')) {return fetchAndProcessPdf(url);} else {- const data = await response.json();- const html = data.content;- return html ?? "";+ const textData = await response.text();+ try {+ 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) {- console.error(`[Playwright][c] Error fetching url: ${url} -> ${error}`);+ console.error(`[Playwright] Error fetching url: ${url} -> ${error}`);return "";}}