Skip to main content
Apify Dataset is a scalable append-only storage with sequential access built for storing structured web scraping results, such as a list of products or Google SERPs, and then export them to various formats like JSON, CSV, or Excel. Datasets are mainly used to save results of Apify Actors—serverless cloud programs for various web scraping, crawling, and data extraction use cases.
This notebook shows how to load Apify datasets to LangChain.

Prerequisites

You need to have an existing dataset on the Apify platform. This example shows how to load a dataset produced by the Website Content Crawler.
First, import ApifyDatasetLoader into your source code:
Find your Apify API token and OpenAI API key and initialize these into environment variable:
Then provide a function that maps Apify dataset record fields to LangChain Document format. For example, if your dataset items are structured like this:
The mapping function in the code below will convert them to LangChain Document format, so that you can use them further with any LLM model (e.g. for question answering).

An example with question answering

In this example, we use data from a dataset to answer a question.