RecursiveUrlLoader는 루트 URL에서 모든 하위 링크를 재귀적으로 스크랩하고 이를 Document로 파싱할 수 있게 해줍니다.
Overview
Integration details
| Class | Package | Local | Serializable | JS support |
|---|---|---|---|---|
| RecursiveUrlLoader | langchain-community | ✅ | ❌ | ✅ |
Loader features
| Source | Document Lazy Loading | Native Async Support |
|---|---|---|
| RecursiveUrlLoader | ✅ | ❌ |
Setup
Credentials
RecursiveUrlLoader를 사용하는 데 필요한 자격 증명은 없습니다.
Installation
RecursiveUrlLoader는 langchain-community 패키지에 포함되어 있습니다. 다른 필수 패키지는 없지만, beautifulsoup4가 설치되어 있으면 더 풍부한 기본 Document metadata를 얻을 수 있습니다.
Instantiation
이제 document loader 객체를 인스턴스화하고 Document를 로드할 수 있습니다:Load
.load()를 사용하여 모든 Document를 메모리에 동기적으로 로드하며, 방문한 URL당 하나의 Document가 생성됩니다. 초기 URL에서 시작하여 지정된 max_depth까지 모든 연결된 URL을 재귀적으로 탐색합니다.
Python 3.9 Documentation에서 RecursiveUrlLoader를 사용하는 기본 예제를 실행해 보겠습니다.
Lazy loading
많은 수의 Document를 로드하고 다운스트림 작업이 로드된 모든 Document의 하위 집합에서 수행될 수 있는 경우, Document를 한 번에 하나씩 지연 로드하여 메모리 사용량을 최소화할 수 있습니다:Adding an Extractor
기본적으로 loader는 각 링크의 원시 HTML을 Document 페이지 콘텐츠로 설정합니다. 이 HTML을 더 사람/LLM 친화적인 형식으로 파싱하려면 사용자 정의extractor 메서드를 전달할 수 있습니다:
metadata_extractor를 전달하여 HTTP 응답에서 Document metadata를 추출하는 방법을 사용자 정의할 수 있습니다. 자세한 내용은 API reference를 참조하세요.
API reference
이 예제들은 기본RecursiveUrlLoader를 수정할 수 있는 몇 가지 방법만 보여주지만, 사용 사례에 가장 적합하도록 수행할 수 있는 수정 사항은 훨씬 더 많습니다. link_regex 및 exclude_dirs 매개변수를 사용하면 원하지 않는 URL을 필터링할 수 있고, aload() 및 alazy_load()는 비동기 로딩에 사용할 수 있으며, 그 외에도 더 많은 기능이 있습니다.
RecursiveUrlLoader 구성 및 호출에 대한 자세한 정보는 API reference를 참조하세요: python.langchain.com/api_reference/community/document_loaders/langchain_community.document_loaders.recursive_url_loader.RecursiveUrlLoader.html.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.