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
import { Actor } from 'apify';
import { ApifyLogAdapter, BasicCrawler, log as defaultLog, LogLevel } from '@crawlee/basic';
const crawlerLogger = new ApifyLogAdapter(
defaultLog.child({
prefix: 'AutoscalingTest',
level: LogLevel.INFO,
}),
);
const mainOptions = {
exit: Actor.isAtHome(),
storage:
process.env.STORAGE_IMPLEMENTATION === 'LOCAL'
? new (await import('@apify/storage-local')).ApifyStorageLocal()
: undefined,
};
let crawlCalledAt = Date.now();
await Actor.main(async () => {
const crawler = new BasicCrawler({
logger: crawlerLogger,
maxRequestsPerMinute: 1,
requestHandler({ log }) {
log.info(`Crawler requestHandler called after ${Date.now() - crawlCalledAt}ms`);
crawlCalledAt = Date.now();
},
});
await crawler.run(['https://example.com/1', 'https://example.com/2']);
}, mainOptions);