I have a problem with omitting saving file to a local file. My problem is how to pass directly the url content to the pdfplumber module. My code is as follows
from pathlib import Path
import urllib3
import pdfplumber
def read_pdf(url: str) -> str:
http = urllib3.PoolManager()
temp = Path('temp.pdf')
temp.write_bytes(http.request("GET", url).data)
with pdfplumber.open(temp) as pdf:
text = pdf.pages[0].extract_text()
temp.unlink()
return text
text = read_pdf('https://sample.com/test.pdf')
It works but I would like to avoid saving file to local but do it in the RAM only. I have tried io.BytesIO but it doesn't work