Skip to content

The agent engineering platform.

Update readthedocs.py (#943)

Usama Navide85c53ce68e7
diff --git a/langchain/document_loaders/readthedocs.py b/langchain/document_loaders/readthedocs.py
index 31d6aa0672..99547f3fb9 100644
--- a/langchain/document_loaders/readthedocs.py
+++ b/langchain/document_loaders/readthedocs.py
@@ -19,7 +19,11 @@ class ReadTheDocsLoader(BaseLoader):
def _clean_data(data: str) -> str:
soup = BeautifulSoup(data)
- text = soup.find_all("main", {"id": "main-content"})[0].get_text()
+ text = soup.find_all("main", {"id": "main-content"})
+ if len(text) != 0:
+ text = text[0].get_text()
+ else:
+ text = ""
return "\n".join([t for t in text.split("\n") if t])
docs = []