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 { Dataset, KeyValueStore } from 'crawlee';
const dataset = await Dataset.open<{
url: string;
headingCount: number;
}>();
// Seeding the dataset with some data
await dataset.pushData([
{
url: 'https://crawlee.dev/',
headingCount: 11,
},
{
url: 'https://crawlee.dev/storage',
headingCount: 8,
},
{
url: 'https://crawlee.dev/proxy',
headingCount: 4,
},
]);
// calling reduce function and using memo to calculate number of headers
const pagesHeadingCount = await dataset.reduce((memo, value) => {
return memo + value.headingCount;
}, 0);
// saving result of map to default Key-value store
await KeyValueStore.setValue('pages_heading_count', pagesHeadingCount);