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
Added Apifier.events EventEmitter
Jan Curnbb5875907a3c
diff --git a/src/index.js b/src/index.jsindex aeb6c52b4..68a9bd30e 100644--- a/src/index.js+++ b/src/index.js@@ -1,3 +1,5 @@+import EventEmitter from 'events';+import { setPromisesDependency, getPromisesDependency } from './utils';import { main, readyFreddy, getContext, getInput, setOutput, apifyClient } from './actor';@@ -10,6 +12,7 @@ const Apifier = {setPromisesDependency,getPromisesDependency,client: apifyClient,+ events: new EventEmitter(),};// export this way so that we can import using:diff --git a/test/actor.js b/test/actor.jsindex 997f93a9e..bd80328bb 100644--- a/test/actor.js+++ b/test/actor.js@@ -500,6 +500,23 @@ describe('Apifier.main()', () => {});+describe('Apifier.events', () => {+ it('is there and works as EventEmitter', () => {+ return new Promise((resolve, reject) => {+ try {+ Apifier.events.on('foo', resolve);+ Apifier.events.emit('foo', 'test event');+ } catch (e) {+ reject(e);+ }+ })+ .then((arg) => {+ expect(arg).to.eql('test event');+ });+ });+});++describe('Apifier.readyFreddy()', () => {it('it works as expected', () => {process.env.APIFY_WATCH_FILE = createWatchFile();