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.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
fix: use namespace imports for cheerio to be compatible with v1 (#2641)
Martin Adámekf48296f6cba7
diff --git a/packages/utils/src/internals/cheerio.ts b/packages/utils/src/internals/cheerio.tsindex 586273ec8..e0cfbc03b 100644--- a/packages/utils/src/internals/cheerio.ts+++ b/packages/utils/src/internals/cheerio.ts@@ -1,6 +1,6 @@import type { Dictionary } from '@crawlee/types';import type { load, CheerioAPI } from 'cheerio';-import cheerio from 'cheerio';+import * as cheerio from 'cheerio';import { tryAbsoluteURL } from './extract-urls';@@ -32,7 +32,7 @@ const BLOCK_TAGS_REGEX =* with the `decodeEntities` option set to `true`. For example:** ```javascript- * import cheerio from 'cheerio';+ * import * as cheerio from 'cheerio';* const html = '<html><body>Some text</body></html>';* const text = htmlToText(cheerio.load(html, { decodeEntities: true }));* ```diff --git a/packages/utils/src/internals/social.ts b/packages/utils/src/internals/social.tsindex 3d415527e..c825fdb01 100644--- a/packages/utils/src/internals/social.ts+++ b/packages/utils/src/internals/social.ts@@ -1,4 +1,4 @@-import cheerio from 'cheerio';+import * as cheerio from 'cheerio';import { htmlToText } from './cheerio';diff --git a/test/utils/cheerio.test.ts b/test/utils/cheerio.test.tsindex a3d7dc0c4..96e2e47dc 100644--- a/test/utils/cheerio.test.ts+++ b/test/utils/cheerio.test.ts@@ -1,6 +1,6 @@import type { CheerioRoot } from '@crawlee/utils';import { htmlToText } from '@crawlee/utils';-import cheerio from 'cheerio';+import * as cheerio from 'cheerio';import * as htmlToTextData from '../shared/data/html_to_text_test_data';