Skip to main content
This notebook provides a quick overview for getting started with CheerioWebBaseLoader document loaders. For detailed documentation of all CheerioWebBaseLoader features and configurations head to the API reference.

概述

集成详情

This example goes over how to load data from webpages using Cheerio. One document will be created for each webpage. Cheerio is a fast and lightweight library that allows you to parse and traverse HTML documents using a jQuery-like syntax. You can use Cheerio to extract data from web pages, without having to render them in a browser. However, Cheerio does not simulate a web browser, so it cannot execute JavaScript code on the page. This means that it cannot extract data from dynamic web pages that require JavaScript to render. To do that, you can use the PlaywrightWebBaseLoader or PuppeteerWebBaseLoader instead.

Loader features

设置

要访问 CheerioWebBaseLoader document loader,你需要install the @langchain/community integration package, along with the cheerio peer dependency.

凭证

如果你想要自动追踪模型调用,还可以设置你的 LangSmith API 密钥,取消注释以下内容:

安装

LangChain 的 CheerioWebBaseLoader 集成位于 @langchain/community 包中:

实例化

Now we can instantiate our model object and load documents:

Load

Additional configurations

CheerioWebBaseLoader supports additional configuration when instantiating the loader. Here is an example of how to use it with the selector field passed, making it only load content from the provided HTML class names:

API 参考

有关所有 CheerioWebBaseLoader 功能和配置的详细文档,请前往 API 参考