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."""
import tempfile
from pathlib import Path
from typing import List
import requests
@ -21,9 +22,9 @@ class OnlinePDFLoader(BaseLoader):
"""Load documents."""
r = requests.get(self.web_path)
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.write(r.content)
file.close()
loader = UnstructuredPDFLoader(file_path)
loader = UnstructuredPDFLoader(str(file_path))
return loader.load()

Loading…
Cancel
Save