You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DocsGPT/application/parser/remote/web_loader.py

24 lines
709 B
Python

from application.parser.remote.base import BaseRemote
from langchain_community.document_loaders import WebBaseLoader
class WebLoader(BaseRemote):
def __init__(self):
self.loader = WebBaseLoader
12 months ago
def load_data(self, inputs):
urls = inputs
1 year ago
if isinstance(urls, str):
urls = [urls]
1 year ago
documents = []
for url in urls:
try:
loader = self.loader(
[url], header_template={"User-Agent": "Mozilla/5.0"}
)
1 year ago
documents.extend(loader.load())
except Exception as e:
print(f"Error processing URL {url}: {e}")
continue
return documents