Skip to main content
This is documentation for SDK for JavaScript | Apify Documentation 3.3, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.4).
Version: 3.3

Add data to dataset

This example saves data to the default dataset. If the dataset doesn't exist, it will be created. You can save data to custom datasets by using Actor.openDataset()

Run on
import { Actor } from 'apify';
import { CheerioCrawler } from 'crawlee';

await Actor.init();

// Create a dataset where we will store the results.
const crawler = new CheerioCrawler({
// Function called for each URL
async requestHandler({ request, body }) {
// Save data to default dataset
await Actor.pushData({
url: request.url,
html: body,
});
},
});

// Run the crawler
await crawler.run([
{ url: 'http://www.example.com/page-1' },
{ url: 'http://www.example.com/page-2' },
{ url: 'http://www.example.com/page-3' },
]);

await Actor.exit();

Each item in this dataset will be saved to its own file in the following directory:

{PROJECT_FOLDER}/storage/datasets/default/
Morty Proxy This is a proxified and sanitized view of the page, visit original site.