跳到主要内容
本示例介绍如何使用 Cheerio 从任何 GitBook 加载数据。每个页面将创建一个文档。

设置

npm
npm install @langchain/community @langchain/core cheerio

从单个 GitBook 页面加载

import { GitbookLoader } from "@langchain/community/document_loaders/web/gitbook";

const loader = new GitbookLoader(
  "https://docs.gitbook.com/product-tour/navigation"
);

const docs = await loader.load();

从给定 GitBook 中的所有路径加载

为此,GitbookLoader 需要使用根路径(本例中为 https://docs.gitbook.com)进行初始化,并将 shouldLoadAllPaths 设置为 true
import { GitbookLoader } from "@langchain/community/document_loaders/web/gitbook";

const loader = new GitbookLoader("https://docs.gitbook.com", {
  shouldLoadAllPaths: true,
});

const docs = await loader.load();

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.