Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beautifulsoup get_text kwargs in WebBaseLoader #6591

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions langchain/document_loaders/web_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class WebBaseLoader(BaseLoader):
requests_kwargs: Dict[str, Any] = {}
"""kwargs for requests"""

bs_get_text_kwargs: Dict[str, Any] = {}
"""kwargs for beatifulsoup4 get_text"""

def __init__(
self,
web_path: Union[str, List[str]],
Expand Down Expand Up @@ -202,7 +205,7 @@ def load(self) -> List[Document]:
docs = []
for path in self.web_paths:
soup = self._scrape(path)
text = soup.get_text()
text = soup.get_text(**self.bs_get_text_kwargs)
metadata = _build_metadata(soup, path)
docs.append(Document(page_content=text, metadata=metadata))

Expand All @@ -215,7 +218,7 @@ def aload(self) -> List[Document]:
docs = []
for i in range(len(results)):
soup = results[i]
text = soup.get_text()
text = soup.get_text(**self.bs_get_text_kwargs)
metadata = _build_metadata(soup, self.web_paths[i])
docs.append(Document(page_content=text, metadata=metadata))

Expand Down