PuppeteerWebBaseLoader document loaders. For detailed documentation of all PuppeteerWebBaseLoader features and configurations head to the API reference.
Puppeteer is a Node.js library that provides a high-level API for controlling headless Chrome or Chromium. You can use Puppeteer to automate web page interactions, including extracting data from dynamic web pages that require JavaScript to render.
If you want a lighterweight solution, and the webpages you want to load do not require JavaScript to render, you can use the CheerioWebBaseLoader instead.
概述
集成详情
Loader features
设置
要访问PuppeteerWebBaseLoader document loader,你需要install the @langchain/community integration package, along with the puppeteer peer dependency.
凭证
如果你想要自动追踪模型调用,还可以设置你的 LangSmith API 密钥,取消注释以下内容:安装
LangChain 的 PuppeteerWebBaseLoader 集成位于@langchain/community 包中:
实例化
Now we can instantiate our model object and load documents:Load
Options
Here’s an explanation of the parameters you can pass to the PuppeteerWebBaseLoader constructor using the PuppeteerWebBaseLoaderOptions interface:-
launchOptions: an optional object that specifies additional options to pass to the puppeteer.launch() method. This can include options such as the headless flag to launch the browser in headless mode, or the slowMo option to slow down Puppeteer’s actions to make them easier to follow. -
gotoOptions: an optional object that specifies additional options to pass to the page.goto() method. This can include options such as the timeout option to specify the maximum navigation time in milliseconds, or the waitUntil option to specify when to consider the navigation as successful. -
evaluate: an optional function that can be used to evaluate JavaScript code on the page using the page.evaluate() method. This can be useful for extracting data from the page or interacting with page elements. The function should return a Promise that resolves to a string containing the result of the evaluation.
PuppeteerWebBaseLoader constructor, you can customize the behavior of the loader and use Puppeteer’s powerful features to scrape and interact with web pages.
Screenshots
To take a screenshot of a site, initialize the loader the same as above, and call the.screenshot() method.
This will return an instance of Document where the page content is a base64 encoded image, and the metadata contains a source field with the URL of the page.
API 参考
有关所有PuppeteerWebBaseLoader 功能和配置的详细文档,请前往 API 参考。
将这些文档连接到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

