langchain_community.document_loaders.gitbook.GitbookLoader

class langchain_community.document_loaders.gitbook.GitbookLoader(web_page: str, load_all_paths: bool = False, base_url: Optional[str] = None, content_selector: str = 'main', continue_on_failure: bool = False)[source]

加载`GitBook`数据。

  1. 从单个页面加载,或

  2. 加载导航栏中的所有(相对)路径。

使用网页和是否加载所有路径进行初始化。

参数:

web_page:要加载的网页或从中发现相对路径的起始点。 load_all_paths:如果设置为True,则加载导航栏中的所有相对路径,而不仅仅是`web_page`。 base_url:如果`load_all_paths`为True,则将相对路径附加到此基本URL。默认为`web_page`。 content_selector:要加载的内容的CSS选择器。默认为”main”。 continue_on_failure:是否在加载URL时发生错误时继续加载站点地图,发出警告而不是引发异常。将此设置为True会使加载器更加健壮,但也可能导致数据丢失。默认值:False

Attributes

web_path

Methods

__init__(web_page[, load_all_paths, ...])

使用网页和是否加载所有路径进行初始化。

alazy_load()

一个用于文档的惰性加载器。

aload()

从web_path中的URL异步加载文本到Documents中。

fetch_all(urls)

以限制速率并发获取所有URL。

lazy_load()

从一个GitBook页面获取文本。

load()

将数据加载到文档对象中。

load_and_split([text_splitter])

加载文档并分割成块。块作为文档返回。

scrape([parser])

从网页中抓取数据并以BeautifulSoup格式返回。

scrape_all(urls[, parser])

获取所有的URL,然后返回所有结果的网页源代码。

Parameters
  • web_page (str) –

  • load_all_paths (bool) –

  • base_url (Optional[str]) –

  • content_selector (str) –

  • continue_on_failure (bool) –

__init__(web_page: str, load_all_paths: bool = False, base_url: Optional[str] = None, content_selector: str = 'main', continue_on_failure: bool = False)[source]

使用网页和是否加载所有路径进行初始化。

参数:

web_page:要加载的网页或从中发现相对路径的起始点。 load_all_paths:如果设置为True,则加载导航栏中的所有相对路径,而不仅仅是`web_page`。 base_url:如果`load_all_paths`为True,则将相对路径附加到此基本URL。默认为`web_page`。 content_selector:要加载的内容的CSS选择器。默认为”main”。 continue_on_failure:是否在加载URL时发生错误时继续加载站点地图,发出警告而不是引发异常。将此设置为True会使加载器更加健壮,但也可能导致数据丢失。默认值:False

Parameters
  • web_page (str) –

  • load_all_paths (bool) –

  • base_url (Optional[str]) –

  • content_selector (str) –

  • continue_on_failure (bool) –

async alazy_load() AsyncIterator[Document]

一个用于文档的惰性加载器。

Return type

AsyncIterator[Document]

aload() List[Document]

从web_path中的URL异步加载文本到Documents中。

Return type

List[Document]

async fetch_all(urls: List[str]) Any

以限制速率并发获取所有URL。

Parameters

urls (List[str]) –

Return type

Any

lazy_load() Iterator[Document][source]

从一个GitBook页面获取文本。

Return type

Iterator[Document]

load() List[Document]

将数据加载到文档对象中。

Return type

List[Document]

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]

加载文档并分割成块。块作为文档返回。

不要覆盖此方法。应该被视为已弃用!

参数:
text_splitter: 用于分割文档的TextSplitter实例。

默认为RecursiveCharacterTextSplitter。

返回:

文档列表。

Parameters

text_splitter (Optional[TextSplitter]) –

Return type

List[Document]

scrape(parser: Optional[str] = None) Any

从网页中抓取数据并以BeautifulSoup格式返回。

Parameters

parser (Optional[str]) –

Return type

Any

scrape_all(urls: List[str], parser: Optional[str] = None) List[Any]

获取所有的URL,然后返回所有结果的网页源代码。

Parameters
  • urls (List[str]) –

  • parser (Optional[str]) –

Return type

List[Any]

Examples using GitbookLoader