Skip to content

Commit

Permalink
Support recursive sitemaps in SitemapLoader (#3146)
Browse files Browse the repository at this point in the history
A (very) simple addition to support multiple sitemap urls.

---------

Co-authored-by: Johann-Peter Hartmann <johann-peter.hartmann@mayflower.de>
  • Loading branch information
2 people authored and vowelparrot committed Apr 28, 2023
1 parent 69d6004 commit 3d762f2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions langchain/document_loaders/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def parse_sitemap(self, soup: Any) -> List[dict]:
}
)

for sitemap in soup.find_all("sitemap"):
loc = sitemap.find("loc")
if not loc:
continue
soup_child = self.scrape_all([loc.text], "xml")[0]

els.extend(self.parse_sitemap(soup_child))
return els

def load(self) -> List[Document]:
Expand Down

0 comments on commit 3d762f2

Please sign in to comment.