searx-api
Harrison Chase 1 year ago committed by GitHub
parent e8f224fd3a
commit 37dd34bea5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
"""Loader that loads online PDF files.""" """Loader that loads online PDF files."""
import tempfile import tempfile
from pathlib import Path
from typing import List from typing import List
import requests import requests
@ -21,9 +22,9 @@ class OnlinePDFLoader(BaseLoader):
"""Load documents.""" """Load documents."""
r = requests.get(self.web_path) r = requests.get(self.web_path)
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
file_path = f"{temp_dir}/online_file.pdf" file_path = Path(temp_dir) / "online_file.pdf"
file = open(file_path, "wb") file = open(file_path, "wb")
file.write(r.content) file.write(r.content)
file.close() file.close()
loader = UnstructuredPDFLoader(file_path) loader = UnstructuredPDFLoader(str(file_path))
return loader.load() return loader.load()

Loading…
Cancel
Save