异步HTML加载器#
- class langchain_community.document_loaders.async_html.AsyncHtmlLoader(web_path: str | List[str], header_template: dict | None = None, verify_ssl: bool | None = True, proxies: dict | None = None, autoset_encoding: bool = True, encoding: str | None = None, default_parser: str = 'html.parser', requests_per_second: int = 2, requests_kwargs: Dict[str, Any] | None = None, raise_for_status: bool = False, ignore_load_errors: bool = False, *, preserve_order: bool = True, trust_env: bool = False)[source]#
异步加载 HTML。
使用网页路径进行初始化。
方法
__init__
(web_path[, header_template, ...])使用网页路径进行初始化。
从web_path中的URL(s)懒加载文本。
aload
()将数据加载到Document对象中。
fetch_all
(urls)并发获取所有URL,并带有速率限制。
从web_path中的URL懒加载文本。
load
()将数据加载到Document对象中。
load_and_split
([text_splitter])加载文档并将其分割成块。
- Parameters:
web_path (str | List[str])
header_template (dict | None)
verify_ssl (bool | None)
proxies (dict | None)
autoset_encoding (bool)
encoding (str | None)
default_parser (str)
requests_per_second (int)
requests_kwargs (Dict[str, Any] | None)
raise_for_status (bool)
ignore_load_errors (bool)
preserve_order (bool)
trust_env (bool)
- __init__(web_path: str | List[str], header_template: dict | None = None, verify_ssl: bool | None = True, proxies: dict | None = None, autoset_encoding: bool = True, encoding: str | None = None, default_parser: str = 'html.parser', requests_per_second: int = 2, requests_kwargs: Dict[str, Any] | None = None, raise_for_status: bool = False, ignore_load_errors: bool = False, *, preserve_order: bool = True, trust_env: bool = False)[source]#
使用网页路径进行初始化。
- Parameters:
web_path (str | List[str])
header_template (dict | None)
verify_ssl (布尔值 | 无)
proxies (dict | None)
autoset_encoding (bool)
encoding (str | None)
default_parser (str)
requests_per_second (int)
requests_kwargs (Dict[str, Any] | None)
raise_for_status (bool)
ignore_load_errors (bool)
preserve_order (bool)
trust_env (bool)
- async alazy_load() AsyncIterator[Document] [source]#
从web_path中的URL懒加载文本。
- Return type:
AsyncIterator[Document]
- async fetch_all(urls: List[str]) List[str] [source]#
同时获取所有URL,并进行速率限制。
- Parameters:
urls (列表[字符串])
- Return type:
列表[str]
- load_and_split(text_splitter: TextSplitter | None = None) list[Document] #
加载文档并将其分割成块。块以文档形式返回。
不要重写此方法。它应该被视为已弃用!
- Parameters:
text_splitter (可选[TextSplitter]) – 用于分割文档的TextSplitter实例。 默认为RecursiveCharacterTextSplitter。
- Returns:
文档列表。
- Return type:
列表[Document]
使用 AsyncHtmlLoader 的示例