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.

chore: drop `got-scraping` as the direct `crawlee` dependency (#3358)

Jindřich Bärf886e46b6b3f
diff --git a/packages/http-crawler/package.json b/packages/http-crawler/package.json
index c735e7253..6cb9ce155 100644
--- a/packages/http-crawler/package.json
+++ b/packages/http-crawler/package.json
@@ -56,7 +56,6 @@
"@types/content-type": "^1.1.8",
"cheerio": "^1.0.0",
"content-type": "^1.0.5",
- "got-scraping": "^4.1.1",
"iconv-lite": "^0.7.0",
"mime-types": "^3.0.1",
"ow": "^2.0.0",
diff --git a/packages/http-crawler/src/internals/http-crawler.ts b/packages/http-crawler/src/internals/http-crawler.ts
index 2d1736fc7..b13b04403 100644
--- a/packages/http-crawler/src/internals/http-crawler.ts
+++ b/packages/http-crawler/src/internals/http-crawler.ts
@@ -33,7 +33,6 @@ import { type CheerioRoot, RETRY_CSS_SELECTORS } from '@crawlee/utils';
import * as cheerio from 'cheerio';
import type { RequestLike, ResponseLike } from 'content-type';
import contentTypeParser from 'content-type';
-import type { TimeoutError as TimeoutErrorClass } from 'got-scraping';
import iconv from 'iconv-lite';
import ow from 'ow';
import type { JsonValue } from 'type-fest';
@@ -42,8 +41,6 @@ import { addTimeoutToPromise, tryCancel } from '@apify/timeout';
import { parseContentTypeFromResponse, processHttpRequestOptions } from './utils.js';
-let TimeoutError: typeof TimeoutErrorClass;
-
/**
* Default mime types, which HttpScraper supports.
*/
@@ -612,17 +609,12 @@ export class HttpCrawler<
proxyUrl,
cookieString,
}: RequestFunctionOptions): Promise<Response> {
- if (!TimeoutError) {
- // @ts-ignore
- ({ TimeoutError } = await import('got-scraping'));
- }
-
const opts = this._getRequestOptions(request, session, proxyUrl);
try {
return await this._requestAsBrowser(opts, session, cookieString);
} catch (e) {
- if (e instanceof TimeoutError) {
+ if (e instanceof Error && e.constructor.name === 'TimeoutError') {
this._handleRequestTimeout(session);
return new Response(); // this will never happen, as _handleRequestTimeout always throws
}