Skip to main content
Open on GitHub

Apify

Apify is a cloud platform for web scraping and data extraction, which provides an ecosystem of more than a thousand ready-made apps called Actors for various scraping, crawling, and extraction use cases.

Apify Actors

此集成使您能够在 Apify 平台上运行 Actors,并将其结果加载到 LangChain 中,以将来自网络的文档和数据馈入您的向量索引,例如从包含文档、博客或知识库的网站生成答案。

安装与设置

  • 使用以下命令安装 Python 的 LangChain Apify 包:
pip install langchain-apify
  • 获取您的 Apify API 令牌,然后将其设置为环境变量(APIFY_API_TOKEN)或在构造函数中以 apify_api_token 的形式传入。

工具

您可以使用 ApifyActorsTool 通过代理使用 Apify Actors。

from langchain_apify import ApifyActorsTool

查看 这个笔记本 了解使用示例,以及在 Apify LangGraph代理Actor模板 中使用LangGraph的完整工具调用代理示例。

有关如何使用此工具的更多信息,请访问 Apify 集成文档

包装器

您可以使用 ApifyWrapper 在 Apify 平台上运行 Actors。

from langchain_apify import ApifyWrapper

有关如何使用此包装器的更多信息,请参阅 Apify 集成文档

文档加载器

您也可以使用我们的 ApifyDatasetLoader 从 Apify 数据集获取数据。

from langchain_apify import ApifyDatasetLoader

有关此加载器的更详细说明,请参见 此笔记本

此集成的源代码可以在 LangChain Apify 仓库 中找到。