Skip to content

Commit

Permalink
Make bs4 a local import in recursive_url_loader.py (langchain-ai#6693)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlancemartin authored Jun 24, 2023
1 parent ef4c7b5 commit dd36adc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion langchain/document_loaders/recursive_url_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from urllib.parse import urlparse

import requests
from bs4 import BeautifulSoup

from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
Expand All @@ -21,6 +20,13 @@ def get_child_links_recursive(
) -> Set[str]:
"""Recursively get all child links starting with the path of the input URL."""

try:
from bs4 import BeautifulSoup
except ImportError:
raise ImportError(
"The BeautifulSoup package is required for the RecusiveUrlLoader."
)

# Construct the base and parent URLs
parsed_url = urlparse(url)
base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"
Expand Down

0 comments on commit dd36adc

Please sign in to comment.