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
Feature/feedback2 (#26)
Jan Čurnecf76f1fce77
diff --git a/src/actor.js b/src/actor.jsindex 4ee6ea002..744e82287 100644--- a/src/actor.js+++ b/src/actor.js@@ -362,14 +362,14 @@ export const call = (actId, input, opts = {}) => {};/**- * Returns a url of Apify Proxy that can be used from Actor acts, web browsers or any other HTTP+ * Returns a URL of Apify Proxy that can be used from Actor acts, web browsers or any other HTTP* proxy-enabled applications.** @param {Object} opts* @param {String} opts.password User proxy password. By default, it is taken from the `APIFY_PROXY_PASSWORD` environment variable.* @param {String} [opts.groups] Proxy groups to be used.* @param {String} [opts.session] Session ID that identifies requests that should use the same proxy connection.- * @returns {String} Returns proxy url.+ * @returns {String} Returns proxy URL.** @memberof module:Apify* @function@@ -384,6 +384,8 @@ export const getApifyProxyUrl = (opts = {}) => {port = parseInt(process.env[ENV_VARS.PROXY_PORT], 10),} = opts;+ // TODO: Check that session and groups are alphanumeric!+checkParamOrThrow(groups, 'opts.groups', 'Maybe Array');checkParamOrThrow(session, 'opts.session', 'Maybe Number | String');checkParamOrThrow(password, 'opts.password', 'String');diff --git a/src/constants.js b/src/constants.jsindex 38b94b251..3014dcc89 100644--- a/src/constants.js+++ b/src/constants.js@@ -34,6 +34,7 @@ consts.ENV_VARS = {HEADLESS: 'APIFY_HEADLESS',INTERNAL_PORT: 'APIFY_INTERNAL_PORT',MEMORY_MBYTES: 'APIFY_MEMORY_MBYTES',+ LOG_LEVEL: 'APIFY_LOG_LEVEL',};consts.KEY_VALUE_STORE_KEYS = {diff --git a/src/index.js b/src/index.jsindex d61aa5c38..458a8733b 100644--- a/src/index.js+++ b/src/index.js@@ -1,6 +1,7 @@import EventEmitter from 'events';import { log } from 'apify-shared';+import { ENV_VARS } from './constants';import { main, readyFreddy, getEnv, call, getApifyProxyUrl } from './actor';import AutoscaledPool from './autoscaled_pool';import BasicCrawler from './basic_crawler';@@ -18,7 +19,7 @@ import { browse, launchWebDriver } from './webdriver';/* globals module */// Hide debug log messages when running in production mode.-if (!isProduction()) log.isDebugMode = true;+if (!isProduction() || process.env[ENV_VARS.LOG_LEVEL] === 'DEBUG') log.isDebugMode = true;/*** The `apify` NPM package simplifies development of acts in Apify Actor -diff --git a/src/puppeteer.js b/src/puppeteer.jsindex 3aa00f8c6..ca9ad7cf1 100644--- a/src/puppeteer.js+++ b/src/puppeteer.js@@ -21,7 +21,7 @@ import { newPromise } from './utils';* to make the proxy work with headless Chrome. For more information, read the* {@link https://blog.apify.com/249a21a79212|blog post about proxy-chain library}.* </li>- * <li>Adds `--no-sandbox` to `args` to enable running headless Chrome in a Docker container on the Actor platform.</li>+ * <li>Adds `--no-sandbox` to `args` to enable running headless Chrome in a Docker container on the Apify Actor platform.</li>* </ul>** To use this function, you need to have the {@link https://www.npmjs.com/package/puppeteer|puppeteer}diff --git a/src/puppeteer_crawler.js b/src/puppeteer_crawler.jsindex 3dc6c3047..c066f0cee 100644--- a/src/puppeteer_crawler.js+++ b/src/puppeteer_crawler.js@@ -105,6 +105,9 @@ export default class PuppeteerCrawler {launchPuppeteerFunction,instanceKillerIntervalMillis,killInstanceAfterMillis,++ // TODO: 'groups' is not a great name, but we need to+ // review proxy settings in generalgroups,puppeteerConfig,disableProxy,diff --git a/src/request.js b/src/request.jsindex 9d3b2f276..cb2e12b52 100644--- a/src/request.js+++ b/src/request.js@@ -5,7 +5,7 @@ import _ from 'underscore';export const computeUniqueKey = (url, keepUrlFragment) => normalizeUrl(url, keepUrlFragment);/**- * Requests class defines a request to be processed and stores info about error that occured during the processing.+ * Requests class defines a web request to be processed and stores info about error that occurred during the processing.** Example use:*@@ -26,7 +26,7 @@ export const computeUniqueKey = (url, keepUrlFragment) => normalizeUrl(url, keep* ```** @param {String} url- * @param {String} [uniqueKey] Unique key indentifying request. In not provided then it's computed as normalized url.+ * @param {String} [uniqueKey] Unique key identifying request. In not provided then it is computed as normalized URL.* @param {String} [method='GET']* @param {String|Buffer} [payload] Request payload. If method='GET' then the payload is not allowed.* @param {Number} [retryCount=0] How many times the url was retried in a case of exception.