Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Added a TODO to Apify.utils.htmlToText()

Jan Curn5b300a44381a
diff --git a/src/utils.js b/src/utils.js
index e3ec43aa1..d32b67b0d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -537,6 +537,9 @@ const htmlToText = (html) => {
// TODO: Add support for "html" being a Cheerio element, otherwise the only way
// to use it is e.g. htmlToText($('p').html())) which is inefficient
+ // Also, it seems this doesn't work well in CheerioScraper, e.g. htmlToText($)
+ // produces really text with a lot of HTML elements in it. Let's just deprecate this sort of usage,
+ // and make the parameter "htmlOrCheerioElement"
/** @type {Cheerio} */
const $ = typeof html === 'function' ? html : cheerio.load(html, { decodeEntities: true });