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.

refactored code and builded docs

Petr Patek5a28fd30872d
diff --git a/docs/api/TimeoutError.md b/docs/api/TimeoutError.md
new file mode 100644
index 000000000..be0f74b83
--- /dev/null
+++ b/docs/api/TimeoutError.md
@@ -0,0 +1,8 @@
+---
+id: timeouterror
+title: TimeoutError
+---
+
+<a name="TimeoutError"></a>
+
+TimeoutError class. This error should be thrown after request timeout from `requestAsBrowser`.
diff --git a/src/errors.js b/src/errors.js
index c3a965ba6..bf956b92b 100644
--- a/src/errors.js
+++ b/src/errors.js
@@ -21,3 +21,8 @@ export class ApifyCallError extends Error {
Error.captureStackTrace(this, ApifyCallError);
}
}
+/**
+ * TimeoutError class.
+ * This error should be thrown after request timeout from `requestAsBrowser`.
+ */
+export class TimeoutError extends Error {}
diff --git a/src/utils_request.js b/src/utils_request.js
index e8b7ebe7b..f2c064c20 100644
--- a/src/utils_request.js
+++ b/src/utils_request.js
@@ -3,6 +3,7 @@ import * as url from 'url';
import _ from 'underscore';
import httpRequest from '@apify/http-request';
import errors from '@apify/http-request/src/errors';
+import { TimeoutError } from './errors';
export const FIREFOX_MOBILE_USER_AGENT = 'Mozilla/5.0 (Android; Mobile; rv:14.0) Gecko/14.0 Firefox/14.0';
export const FIREFOX_DESKTOP_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0';
@@ -91,10 +92,4 @@ export const requestAsBrowser = async (options) => {
throw e;
}
-
};
-
-/**
- * TimeoutError helper class
- */
-export class TimeoutError extends Error {}