> For the complete documentation index, see [llms.txt](https://organization-bht.gitbook.io/it/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://organization-bht.gitbook.io/it/ai/4-rag/document-loader/undefined.md). Agents can also search and read this documentation through its [MCP server](https://organization-bht.gitbook.io/it/~gitbook/mcp).

# 전체 코드

```
#1. 텍스트 파일 로드
from langchain_community.document_loaders import TextLoader

loader = TextLoader("example.txt") # 영어로작성
documents = loader.load()

# 로드된 문서 확인
#print(documents)

# 2. PDF 문서 로드
from langchain_community.document_loaders import PyPDFLoader

loader = PyPDFLoader("쬬조_세미프로젝트 보고서.pdf")
documents = loader.load()

# 출력
#print(documents[7].page_content)  # 7 페이지 내용 출력

# 3. 웹문서 로드
from langchain_community.document_loaders import WebBaseLoader
import bs4

# 웹사이트 크롤링 후 텍스트 추출
loader = WebBaseLoader(web_paths=
                       ("https://khedu.co.kr/main/main.kh",) ,
                        bs_kwargs=dict(
                        parse_only=bs4.SoupStrainer( #크롤링할 태그, 클래스 등 설정 가능
                            ["section" , "div"],
                            # attrs={"class": ["content_section"]},
                        )
                    ),
                    header_template={
                        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36",
                    },
                       )
loader.requests_kwargs = {"verify": False} # ssl인증 우회
documents = loader.load()

# 웹 페이지의 텍스트 출력
print(documents[0].page_content)
```
