mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
24 lines
709 B
Python
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
|
|
|
|
def load_data(self, inputs):
|
|
urls = inputs
|
|
if isinstance(urls, str):
|
|
urls = [urls]
|
|
documents = []
|
|
for url in urls:
|
|
try:
|
|
loader = self.loader(
|
|
[url], header_template={"User-Agent": "Mozilla/5.0"}
|
|
)
|
|
documents.extend(loader.load())
|
|
except Exception as e:
|
|
print(f"Error processing URL {url}: {e}")
|
|
continue
|
|
return documents
|