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
Fixed tests and increased client version
Jaroslav Hejlekc978f6553ec8
diff --git a/package.json b/package.jsonindex 033130f83..8462ba19a 100644--- a/package.json+++ b/package.json@@ -43,7 +43,7 @@"lint": "npm run build && eslint src test"},"dependencies": {- "apify-client": "^0.1.55",+ "apify-client": "^0.1.61","bluebird": "^3.5.0","content-type": "^1.0.3","proxy-chain": "^0.1.2",diff --git a/src/actor.js b/src/actor.jsindex febd1b444..c6fb21cf3 100644--- a/src/actor.js+++ b/src/actor.js@@ -320,7 +320,7 @@ export const setValue = (key, value, options, callback = null) => {* @returns {Promise} Returns a promise if `callback` was not provided.*/export const pushItem = (item, callback = null) => {- if (!record || !_.isObject(record) || _.isArray(record)) throw new Error('The "item" parameter must be an object');+ if (!item || !_.isObject(item) || _.isArray(item)) throw new Error('The "item" parameter must be an object');if (callback && !_.isFunction(callback)) throw new Error('If provided then the "callback" parameter must be a function');const promisePrototype = getPromisePrototype();@@ -406,7 +406,7 @@ export const getEnv = () => {startedAt: tryParseDate(env[ENV_VARS.STARTED_AT]) || null,timeoutAt: tryParseDate(env[ENV_VARS.TIMEOUT_AT]) || null,defaultKeyValueStoreId: env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID] || null,- defaultSequentialStoreId: env[ENV_VARS.DEFAULT_SEQUENTIAL_STORE_ID] || null,+ defaultDatasetId: env[ENV_VARS.DEFAULT_DATASET_ID] || null,// internalPort: parseInt(env[ENV_VARS.INTERNAL_PORT], 10) || null,memoryMbytes: parseInt(env[ENV_VARS.MEMORY_MBYTES], 10) || null,};diff --git a/src/constants.js b/src/constants.jsindex daf0d4b9e..6e5ea00d3 100644--- a/src/constants.js+++ b/src/constants.js@@ -23,7 +23,7 @@ export const ENV_VARS = {STARTED_AT: 'APIFY_STARTED_AT',TIMEOUT_AT: 'APIFY_TIMEOUT_AT',DEFAULT_KEY_VALUE_STORE_ID: 'APIFY_DEFAULT_KEY_VALUE_STORE_ID',- DEFAULT_SEQUENTIAL_STORE_ID: 'APIFY_DEFAULT_SEQUENTIAL_STORE_ID',+ DEFAULT_DATASET_ID: 'APIFY_DEFAULT_DATASET_ID',DEV_KEY_VALUE_STORE_DIR: 'APIFY_DEV_KEY_VALUE_STORE_DIR',DEV_KEY_VALUE_STORE_CONTENT_TYPE: 'APIFY_DEV_KEY_VALUE_STORE_CONTENT_TYPE',WATCH_FILE: 'APIFY_WATCH_FILE',diff --git a/src/index.js b/src/index.jsindex 4e791c9bf..efe88679b 100644--- a/src/index.js+++ b/src/index.js@@ -1,7 +1,7 @@import EventEmitter from 'events';import { setPromisesDependency, getPromisesDependency } from './utils';-import { main, readyFreddy, getEnv, getValue, setValue, pushRecord, apifyClient, call, getMemoryInfo } from './actor';+import { main, readyFreddy, getEnv, getValue, setValue, pushItem, apifyClient, call, getMemoryInfo } from './actor';import { launchPuppeteer } from './puppeteer';import { browse, launchWebDriver } from './webdriver';@@ -13,7 +13,7 @@ const Apify = {getEnv,getValue,setValue,- pushRecord,+ pushItem,call,readyFreddy,setPromisesDependency,diff --git a/test/actor.js b/test/actor.jsindex 4584b237d..68894b7f1 100644--- a/test/actor.js+++ b/test/actor.js@@ -200,7 +200,7 @@ const getEmptyEnv = () => {startedAt: null,timeoutAt: null,defaultKeyValueStoreId: null,- defaultSequentialStoreId: null,+ defaultDatasetId: null,memoryMbytes: null,};};@@ -214,6 +214,7 @@ const setEnv = (env) => {delete process.env.APIFY_STARTED_AT;delete process.env.APIFY_TIMEOUT_AT;delete process.env.APIFY_DEFAULT_KEY_VALUE_STORE_ID;+ delete process.env.APIFY_DEFAULT_DATASET_ID;// if (env.internalPort) process.env.APIFY_INTERNAL_PORT = env.internalPort.toString();if (env.actId) process.env.APIFY_ACT_ID = env.actId;@@ -223,7 +224,7 @@ const setEnv = (env) => {if (env.startedAt) process.env.APIFY_STARTED_AT = env.startedAt.toISOString();if (env.timeoutAt) process.env.APIFY_TIMEOUT_AT = env.timeoutAt.toISOString();if (env.defaultKeyValueStoreId) process.env.APIFY_DEFAULT_KEY_VALUE_STORE_ID = env.defaultKeyValueStoreId;- if (env.defaultSequentialStoreId) process.env.APIFY_DEFAULT_SEQUENTIAL_STORE_ID = env.defaultSequentialStoreId;+ if (env.defaultDatasetId) process.env.APIFY_DEFAULT_DATASET_ID = env.defaultDatasetId;if (env.memoryMbytes) process.env.APIFY_MEMORY_MBYTES = env.memoryMbytes.toString();};@@ -246,7 +247,7 @@ describe('Apify.getEnv()', () => {startedAt: new Date('2017-01-01'),timeoutAt: new Date(),defaultKeyValueStoreId: 'some store',- defaultSequentialStoreId: 'some sequential store',+ defaultDatasetId: 'some dataset',memoryMbytes: 1234,});setEnv(expectedEnv);@@ -963,7 +964,7 @@ describe('Apify.pushItem()', () => {process.env.APIFY_DEFAULT_DATASET_ID = '';expect(() => { Apify.pushItem({ something: 123 }); }).to.throw(Error, errMsg);- delete process.env.APIFY_DEFAULT_SEQUENTIAL_STORE_ID;+ delete process.env.APIFY_DEFAULT_DATASET_ID;expect(() => { Apify.pushItem({ something: 123 }); }).to.throw(Error, errMsg);});@@ -1048,7 +1049,7 @@ describe('Apify.pushItem()', () => {Apify.setPromisesDependency(Promise);- const mock = sinon.mock(Apify.client.sequentialStores);+ const mock = sinon.mock(Apify.client.datasets);mock.expects('putItem').once().withArgs({